Changes to MGC class library and fix a bug regarding nested inline class declaration
[IRC.git] / Robust / src / ClassLibrary / MGC / Thread.java
index af67dbf7e8592b9670bec3a4126191a82c3ad60e..09cd470ef1caeef6989e19d86cef7b2bbde1faee 100644 (file)
@@ -1,16 +1,34 @@
 public class Thread implements Runnable {
+  static long id = 0;
   private boolean finished;
   Runnable target;
+  private boolean daemon;
+  private long threadId;
+  String name;
   
   public Thread(){
     finished = false;
     target = null;
+    daemon = false;
+    threadId = Thread.id++;
+  }
+  
+  public long getId()
+  {
+    return threadId;
   }
   
   public Thread(Runnable r) {
     finished = false;
     target = r;
   }
+  
+  public Thread(Runnable r, String n)
+  {
+    finished = false;
+    target = r;
+    name = n;
+  }
 
   public void start() {
     nativeCreate();
@@ -18,6 +36,7 @@ public class Thread implements Runnable {
 
   private static void staticStart(Thread t) {
     t.run();
+    t.finished = true;
   }
 
   public static native void yield();
@@ -34,8 +53,28 @@ public class Thread implements Runnable {
     if(target != null) {
       target.run();
     }
+    this.finished = true;
   }
 
   private native void nativeCreate();
+  
+  public final boolean isAlive() {
+    return !this.finished;
+  }
+  
+  public native ThreadLocalMap getThreadLocals();
+  
+  public final synchronized void setDaemon(boolean daemon) {
+    /*if (vmThread != null)
+      throw new IllegalThreadStateException();
+    checkAccess();*/
+    this.daemon = daemon;
+  }
+  
+  public static Thread currentThread()
+  {
+    System.out.println("Unimplemented Thread.currentThread()!");
+    return null;
+  }
 
 }