changes to MGC class library
[IRC.git] / Robust / src / ClassLibrary / MGC / Thread.java
1 public class Thread implements Runnable {
2   static long id = 0;
3   private boolean finished;
4   Runnable target;
5   private boolean daemon;
6   private long threadId;
7   String name;
8   
9   public Thread(){
10     finished = false;
11     target = null;
12     daemon = false;
13     threadId = Thread.id++;
14   }
15   
16   public long getId()
17   {
18     return threadId;
19   }
20   
21   public Thread(Runnable r) {
22     finished = false;
23     target = r;
24   }
25   
26   public Thread(Runnable r, String n)
27   {
28     finished = false;
29     target = r;
30     name = n;
31   }
32
33   public void start() {
34     nativeCreate();
35   }
36
37   private static void staticStart(Thread t) {
38     t.run();
39     t.finished = true;
40   }
41
42   public static native void yield();
43
44   public void join() {
45     nativeJoin();
46   }
47
48   private native void nativeJoin();
49
50   public native static void sleep(long millis);
51
52   public void run() {
53     if(target != null) {
54       target.run();
55     }
56     this.finished = true;
57   }
58
59   private native void nativeCreate();
60   
61   public final boolean isAlive() {
62     return !this.finished;
63   }
64   
65   public native ThreadLocalMap getThreadLocals();
66   
67   public final synchronized void setDaemon(boolean daemon) {
68     /*if (vmThread != null)
69       throw new IllegalThreadStateException();
70     checkAccess();*/
71     this.daemon = daemon;
72   }
73   
74   public static Thread currentThread()
75   {
76     System.out.println("Unimplemented Thread.currentThread()!");
77     return null;
78   }
79   
80   public static Map getAllStackTraces() {
81     System.out.println("Unimplemented Thread.getAllStackTraces()");
82     return new HashMap();
83   }
84
85 }