Methods Summary |
---|
public static native int | activeCount()Returns the current number of active threads in the VM.
|
public static native java.lang.Thread | currentThread()Returns a reference to the currently executing thread object.
|
public final int | getPriority()Returns this thread's priority.
return priority;
|
private native synchronized void | internalExit()
|
public final native boolean | isAlive()Tests if this thread is alive. A thread is alive if it has
been started and has not yet died.
|
public final synchronized void | join()Waits for this thread to die.
while (isAlive()) {
wait(1000);
}
|
public void | run()If this thread was constructed using a separate
Runnable run object, then that
Runnable object's run method is called;
otherwise, this method does nothing and returns.
Subclasses of Thread should override this method.
if (target != null) {
target.run();
}
|
public final void | setPriority(int newPriority)Changes the priority of this thread.
if (newPriority > MAX_PRIORITY || newPriority < MIN_PRIORITY) {
throw new IllegalArgumentException();
}
setPriority0(priority, newPriority);
priority = newPriority;
|
private native void | setPriority0(int oldPriority, int newPriority)
|
public static native void | sleep(long millis)Causes the currently executing thread to sleep (temporarily cease
execution) for the specified number of milliseconds. The thread
does not lose ownership of any monitors.
|
public synchronized void | start()Causes this thread to begin execution; the Java Virtual Machine
calls the run method of this thread.
The result is that two threads are running concurrently: the
current thread (which returns from the call to the
start method) and the other thread (which executes its
run method).
start(this);
|
private static synchronized void | start(java.lang.Thread thread)
thread.start0();
|
private native void | start0()
|
public java.lang.String | toString()Returns a string representation of this thread, including a unique number
that identifies the thread and the thread's priority.
return "Thread[@" + hashCode() + "," + getPriority() + "]";
|
public static native void | yield()Causes the currently executing thread object to temporarily pause
and allow other threads to execute.
|