1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.hadoop.hbase.util;
19
20 import org.apache.hadoop.hbase.classification.InterfaceAudience;
21
22 import java.lang.Thread.UncaughtExceptionHandler;
23
24
25
26
27
28
29
30
31
32 @InterfaceAudience.Private
33 public abstract class HasThread implements Runnable {
34 private final Thread thread;
35
36 public HasThread() {
37 this.thread = new Thread(this);
38 }
39
40 public HasThread(String name) {
41 this.thread = new Thread(this, name);
42 }
43
44 public Thread getThread() {
45 return thread;
46 }
47
48 public abstract void run();
49
50
51
52 public final String getName() {
53 return thread.getName();
54 }
55
56 public void interrupt() {
57 thread.interrupt();
58 }
59
60 public final boolean isAlive() {
61 return thread.isAlive();
62 }
63
64 public boolean isInterrupted() {
65 return thread.isInterrupted();
66 }
67
68 public final void setDaemon(boolean on) {
69 thread.setDaemon(on);
70 }
71
72 public final void setName(String name) {
73 thread.setName(name);
74 }
75
76 public final void setPriority(int newPriority) {
77 thread.setPriority(newPriority);
78 }
79
80 public void setUncaughtExceptionHandler(UncaughtExceptionHandler eh) {
81 thread.setUncaughtExceptionHandler(eh);
82 }
83
84 public void start() {
85 thread.start();
86 }
87
88 public final void join() throws InterruptedException {
89 thread.join();
90 }
91
92 public final void join(long millis, int nanos) throws InterruptedException {
93 thread.join(millis, nanos);
94 }
95
96 public final void join(long millis) throws InterruptedException {
97 thread.join(millis);
98 }
99
100 }