2007-07-04 22:27:08 +00:00
|
|
|
package java.lang;
|
|
|
|
|
2007-07-21 20:44:39 +00:00
|
|
|
import java.util.Map;
|
|
|
|
import java.util.WeakHashMap;
|
|
|
|
|
2007-07-04 22:27:08 +00:00
|
|
|
public class Thread implements Runnable {
|
|
|
|
private final Runnable task;
|
2007-07-21 20:44:39 +00:00
|
|
|
private Map<ThreadLocal, Object> locals;
|
2007-07-07 18:09:16 +00:00
|
|
|
private long peer;
|
2007-07-04 22:27:08 +00:00
|
|
|
|
|
|
|
public Thread(Runnable task) {
|
|
|
|
this.task = task;
|
|
|
|
}
|
|
|
|
|
2007-07-07 18:09:16 +00:00
|
|
|
public synchronized native void start();
|
2007-07-04 22:27:08 +00:00
|
|
|
|
|
|
|
public void run() {
|
|
|
|
if (task != null) {
|
|
|
|
task.run();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-21 20:44:39 +00:00
|
|
|
public Map<ThreadLocal, Object> locals() {
|
|
|
|
if (locals == null) {
|
|
|
|
locals = new WeakHashMap();
|
|
|
|
}
|
|
|
|
return locals;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static native Thread currentThread();
|
|
|
|
|
2007-07-04 22:27:08 +00:00
|
|
|
public static native void sleep(long milliseconds)
|
|
|
|
throws InterruptedException;
|
|
|
|
}
|