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 @Override
49 public abstract void run();
50
51
52
53 public final String getName() {
54 return thread.getName();
55 }
56
57 public void interrupt() {
58 thread.interrupt();
59 }
60
61 public final boolean isAlive() {
62 return thread.isAlive();
63 }
64
65 public boolean isInterrupted() {
66 return thread.isInterrupted();
67 }
68
69 public final void setDaemon(boolean on) {
70 thread.setDaemon(on);
71 }
72
73 public final void setName(String name) {
74 thread.setName(name);
75 }
76
77 public final void setPriority(int newPriority) {
78 thread.setPriority(newPriority);
79 }
80
81 public void setUncaughtExceptionHandler(UncaughtExceptionHandler eh) {
82 thread.setUncaughtExceptionHandler(eh);
83 }
84
85 public void start() {
86 thread.start();
87 }
88
89 public final void join() throws InterruptedException {
90 thread.join();
91 }
92
93 public final void join(long millis, int nanos) throws InterruptedException {
94 thread.join(millis, nanos);
95 }
96
97 public final void join(long millis) throws InterruptedException {
98 thread.join(millis);
99 }
100
101 }