changes
[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   
8   public Thread(){
9     finished = false;
10     target = null;
11     daemon = false;
12     threadId = Thread.id++;
13   }
14   
15   public long getId()
16   {
17     return threadId;
18   }
19   
20   public Thread(Runnable r) {
21     finished = false;
22     target = r;
23   }
24
25   public void start() {
26     nativeCreate();
27   }
28
29   private static void staticStart(Thread t) {
30     t.run();
31     t.finished = true;
32   }
33
34   public static native void yield();
35
36   public void join() {
37     nativeJoin();
38   }
39
40   private native void nativeJoin();
41
42   public native static void sleep(long millis);
43
44   public void run() {
45     if(target != null) {
46       target.run();
47     }
48     this.finished = true;
49   }
50
51   private native void nativeCreate();
52   
53   public final boolean isAlive() {
54     return !this.finished;
55   }
56   
57   public native ThreadLocalMap getThreadLocals();
58   
59   public final synchronized void setDaemon(boolean daemon) {
60     /*if (vmThread != null)
61       throw new IllegalThreadStateException();
62     checkAccess();*/
63     this.daemon = daemon;
64   }
65   
66   public static Thread currentThread()
67   {
68     System.out.println("Unimplemented Thread.currentThread()!");
69     return null;
70   }
71
72 }