Methods in the Thread Class

1. Constructors

public Thread()

public Thread(Runnable target)

public Thread(ThreadGroup group, Runnable target)

public Thread(String name)

public Thread(ThreadGroup group, String name)

public Thread(Runnable target, String name)

public Thread(ThreadGroup group, Runnable target, String name)

2. Constants

public final int MAX_PRIORITY

public final int MIN_PRIORITY

public final int NORM_PRIORITY

3. Methods

public static int activeCount()

public void checkAccess()

public native int countStackFrames()

public static native Thread currentThread()

Note that currentThread is static, so can be called anywhere. public void destroy() [Java 1.1]

public static void dumpStack()

public static int enumerate(Thread[] groupThreads)

public final String getName()

public final int getPriority()

public final ThreadGroup getThreadGroup()

public void interrupt()

public static boolean interrupted()

public final native boolean isAlive()

public final boolean isDaemon()

public boolean isInterrupted()

public final void join() throws InterruptedException

public final synchronized join(long milliseconds) throws InterruptedException

public final synchronized join(long milliseconds, int nanoseconds) throws InterruptedException

public final native void notify()

public final native void notifyAll()

public final void resume() public void run()

public final void setDaemon(boolean becomeDaemon)

public final void setName(String threadName)

public final void setPriority(int threadPriority)

public static native void sleep(long milliseconds) throws InterruptedException

Note that sleep is static, so can be called anywhere.

public static native void sleep(long milliseconds, int nanoseconds) throws InterruptedException

public synchronized native void start()

public final void stop()

Stay away from this method! A better way to stop a thread is to have the thread’s run method check a flag every time around its loop. Just change the flag to stop the thread. This gives you much better control over where in the code the thread gets stopped, and lets you perform cleanup operations.

public final synchronized void stop(Throwable stopError)

public final void suspend()

public final void wait() throws InterruptedException

public final void wait(long milliseconds) throws InterruptedException

public final void wait(long milliseconds, int nanoseconds) throws InterruptedException public static native void yield()

    Still needed on most Unix implementations.

© 1996-99 Marty Hall, 1999 Lawrence M. Brown