home *** CD-ROM | disk | FTP | other *** search
- package java.lang;
-
- public class Thread implements Runnable {
- private char[] name;
- private int priority;
- private Thread threadQ;
- private int PrivateInfo;
- private int eetop;
- private boolean single_step;
- private boolean daemon = false;
- private boolean stillborn = false;
- private Runnable target;
- private boolean interruptRequested = false;
- private static Thread activeThreadQ;
- private ThreadGroup group;
- private static int threadInitNumber;
- public static final int MIN_PRIORITY = 1;
- public static final int NORM_PRIORITY = 5;
- public static final int MAX_PRIORITY = 10;
-
- private static synchronized int nextThreadNum() {
- return threadInitNumber++;
- }
-
- public static native Thread currentThread();
-
- public static native void yield();
-
- public static native void sleep(long var0) throws InterruptedException;
-
- public static void sleep(long millis, int nanos) throws InterruptedException {
- if (nanos > 500000) {
- ++millis;
- }
-
- sleep(millis);
- }
-
- private void init(ThreadGroup g, Runnable target, String name) {
- Thread parent = currentThread();
- if (g == null) {
- g = parent.getThreadGroup();
- } else {
- g.checkAccess(2);
- }
-
- this.group = g;
- this.daemon = parent.isDaemon();
- this.priority = parent.getPriority();
- this.name = name.toCharArray();
- this.target = target;
- this.setPriority0(this.priority);
- g.add(this);
- }
-
- public Thread() {
- this.init((ThreadGroup)null, (Runnable)null, "Thread-" + nextThreadNum());
- }
-
- public Thread(Runnable target) {
- this.init((ThreadGroup)null, target, "Thread-" + nextThreadNum());
- }
-
- public Thread(ThreadGroup group, Runnable target) {
- this.init(group, target, "Thread-" + nextThreadNum());
- }
-
- public Thread(String name) {
- this.init((ThreadGroup)null, (Runnable)null, name);
- }
-
- public Thread(ThreadGroup group, String name) {
- this.init(group, (Runnable)null, name);
- }
-
- public Thread(Runnable target, String name) {
- this.init((ThreadGroup)null, target, name);
- }
-
- public Thread(ThreadGroup group, Runnable target, String name) {
- this.init(group, target, name);
- }
-
- public synchronized native void start();
-
- public void run() {
- if (this.target != null) {
- this.target.run();
- }
-
- }
-
- private void exit() {
- if (this.group != null) {
- this.group.remove(this);
- this.group = null;
- }
-
- }
-
- public final void stop() {
- SecurityManager.setScopePermission();
- this.stop(new ThreadDeath());
- }
-
- public final synchronized void stop(Throwable o) {
- SecurityManager.checksAccess(this, o, 1);
- this.stop0(o);
- }
-
- public void interrupt() {
- this.interruptRequested = true;
- }
-
- public static boolean interrupted() {
- return currentThread().interruptRequested;
- }
-
- public boolean isInterrupted() {
- return this.interruptRequested;
- }
-
- public void destroy() {
- throw new NoSuchMethodError();
- }
-
- public final native boolean isAlive();
-
- public final void suspend() {
- SecurityManager.checksAccess(this, 1);
- System.err.println("Warning: Thread.suspend() was called; Navigator deadlock might result");
- this.suspend0();
- }
-
- public final void resume() {
- SecurityManager.checksAccess(this, 1);
- this.resume0();
- }
-
- public final void setPriority(int newPriority) {
- try {
- SecurityManager.checksAccess(this, 1);
- } catch (SecurityException var2) {
- return;
- }
-
- if (newPriority <= 10 && newPriority >= 1) {
- if (newPriority > this.group.getMaxPriority()) {
- newPriority = this.group.getMaxPriority();
- }
-
- this.setPriority0(this.priority = newPriority);
- } else {
- throw new IllegalArgumentException();
- }
- }
-
- public final int getPriority() {
- return this.priority;
- }
-
- public final void setName(String name) {
- SecurityManager.checksAccess(this, 1);
- this.name = name.toCharArray();
- }
-
- public final String getName() {
- return String.valueOf(this.name);
- }
-
- public final ThreadGroup getThreadGroup() {
- return this.group;
- }
-
- public static int activeCount() {
- return currentThread().getThreadGroup().activeCount();
- }
-
- public static int enumerate(Thread[] tarray) {
- return currentThread().getThreadGroup().enumerate(tarray);
- }
-
- public native int countStackFrames();
-
- public final synchronized void join(long millis) throws InterruptedException {
- if (millis == 0L) {
- while(this.isAlive()) {
- this.wait(0L);
- }
-
- } else {
- long base = System.currentTimeMillis();
-
- for(long now = 0L; this.isAlive(); now = System.currentTimeMillis() - base) {
- long delay = millis - now;
- if (delay <= 0L) {
- break;
- }
-
- this.wait(delay);
- }
-
- }
- }
-
- public final synchronized void join(long millis, int nanos) throws InterruptedException {
- if (nanos >= 500000 || millis == 0L) {
- ++millis;
- }
-
- this.join(millis);
- }
-
- public final void join() throws InterruptedException {
- this.join(0L);
- }
-
- public static void dumpStack() {
- (new Exception("Stack trace")).printStackTrace();
- }
-
- public final void setDaemon(boolean on) {
- SecurityManager.checksAccess(this, 1);
- if (this.isAlive()) {
- throw new IllegalThreadStateException();
- } else {
- this.daemon = on;
- }
- }
-
- public final boolean isDaemon() {
- return this.daemon;
- }
-
- public void checkAccess() {
- SecurityManager.checksAccess(this, 2);
- }
-
- public String toString() {
- return "Thread[" + this.getName() + "," + this.getPriority() + "," + this.getThreadGroup().getName() + "]";
- }
-
- private native void setPriority0(int var1);
-
- private native void stop0(Object var1);
-
- private native void suspend0();
-
- private native void resume0();
- }
-