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 java.lang.Thread.UncaughtExceptionHandler;
21
22
23
24
25
26
27
28
29
30 public abstract class HasThread implements Runnable {
31 private final Thread thread;
32
33 public HasThread() {
34 this.thread = new Thread(this);
35 }
36
37 public HasThread(String name) {
38 this.thread = new Thread(this, name);
39 }
40
41 public Thread getThread() {
42 return thread;
43 }
44
45 public abstract void run();
46
47
48
49 public final String getName() {
50 return thread.getName();
51 }
52
53 public void interrupt() {
54 thread.interrupt();
55 }
56
57 public final boolean isAlive() {
58 return thread.isAlive();
59 }
60
61 public boolean isInterrupted() {
62 return thread.isInterrupted();
63 }
64
65 public final void setDaemon(boolean on) {
66 thread.setDaemon(on);
67 }
68
69 public final void setName(String name) {
70 thread.setName(name);
71 }
72
73 public final void setPriority(int newPriority) {
74 thread.setPriority(newPriority);
75 }
76
77 public void setUncaughtExceptionHandler(UncaughtExceptionHandler eh) {
78 thread.setUncaughtExceptionHandler(eh);
79 }
80
81 public void start() {
82 thread.start();
83 }
84
85 public final void join() throws InterruptedException {
86 thread.join();
87 }
88
89 public final void join(long millis, int nanos) throws InterruptedException {
90 thread.join(millis, nanos);
91 }
92
93 public final void join(long millis) throws InterruptedException {
94 thread.join(millis);
95 }
96
97 }