public class Thread extends Object implements Runnable
exit
Runtime
run
run
class PrimeThread extends Thread { long minPrime; PrimeThread(long minPrime) { this.minPrime = minPrime; } public void run() { // compute primes larger than minPrime . . . } }
PrimeThread p = new PrimeThread(143); p.start();
class PrimeRun implements Runnable { long minPrime; PrimeRun(long minPrime) { this.minPrime = minPrime; } public void run() { // compute primes larger than minPrime . . . } }
PrimeRun p = new PrimeRun(143); new Thread(p).start();
Runnable
Runtime.exit(int)
run()
stop()
|
|
---|---|
|
|
|
|
|
|
---|---|
|
|
|
|
|
|
|
---|
|
|
|
|
|
|
|
|
|
|
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static final int MIN_PRIORITY
public static final int NORM_PRIORITY
public static final int MAX_PRIORITY
public Thread()
Thread
(null, null, gname)
gname
"Thread-"+
public Thread( Runnable target)
Thread
(null, target, gname)
gname
"Thread-"+
target
run
null
run
public Thread( ThreadGroup group, Runnable target)
Thread
(group, target, gname)
gname
"Thread-"+
group
null
SecurityManager.getThreadGroup()
null
target
run
null
SecurityException
public Thread( String name)
name
public Thread( ThreadGroup group, String name)
group
null
SecurityManager.getThreadGroup()
null
name
SecurityException
public Thread( Runnable target, String name)
Thread
(null, target, name)
target
run
null
name
public Thread( ThreadGroup group, Runnable target, String name)
Thread
target
name
group
group
null
SecurityManager.getThreadGroup()
null
target
run
null
name
SecurityException
public Thread( ThreadGroup group, Runnable target, String name, long stackSize)
Thread
target
name
group
group
null
SecurityManager.getThreadGroup()
null
target
run
null
name
stackSize
SecurityException
public static Thread currentThread()
public static void yield()
public static void sleep(long millis) throws InterruptedException
millis
IllegalArgumentException
millis
InterruptedException
public static void sleep(long millis, int nanos) throws InterruptedException
millis
nanos
0-999999
IllegalArgumentException
millis
nanos
0-999999
InterruptedException
protected Object clone() throws CloneNotSupportedException
clone
Object
CloneNotSupportedException
Cloneable
public void start()
run
IllegalThreadStateException
run()
stop()
public void run()
Runnable
Runnable
run
run
Runnable
start()
stop()
Thread(ThreadGroup, Runnable, String)
@Deprecated public final void stop()
ThreadDeath
stop
interrupt
SecurityException
interrupt()
checkAccess()
run()
start()
ThreadDeath
ThreadGroup.uncaughtException(Thread,Throwable)
SecurityManager.checkAccess(Thread)
SecurityManager.checkPermission(java.security.Permission)
@Deprecated public final void stop( Throwable obj)
stop()
obj
SecurityException
NullPointerException
interrupt()
checkAccess()
run()
start()
stop()
SecurityManager.checkAccess(Thread)
SecurityManager.checkPermission(java.security.Permission)
public void interrupt()
SecurityException
public static boolean interrupted()
true
false
isInterrupted()
public boolean isInterrupted()
true
false
interrupted()
@Deprecated public void destroy()
suspend()
NoSuchMethodError
public final boolean isAlive()
true
false
@Deprecated public final void suspend()
resume
SecurityException
checkAccess()
@Deprecated public final void resume()
suspend()
SecurityException
checkAccess()
suspend()
public final void setPriority(int newPriority)
newPriority
IllegalArgumentException
MIN_PRIORITY
MAX_PRIORITY
SecurityException
getPriority()
checkAccess()
getThreadGroup()
MAX_PRIORITY
MIN_PRIORITY
ThreadGroup.getMaxPriority()
public final int getPriority()
setPriority(int)
public final void setName( String name)
name
name
SecurityException
getName()
checkAccess()
public final String getName()
setName(String)
public final ThreadGroup getThreadGroup()
public static int activeCount()
public static int enumerate( Thread [] tarray)
ThreadGroup.enumerate(Thread[])
tarray
SecurityException
ThreadGroup.checkAccess()
@Deprecated public int countStackFrames()
suspend()
IllegalThreadStateException
public final void join(long millis) throws InterruptedException
millis
zero
millis
IllegalArgumentException
millis
InterruptedException
public final void join(long millis, int nanos) throws InterruptedException
millis
nanos
millis
nanos
0-999999
IllegalArgumentException
millis
nanos
0-999999
InterruptedException
public final void join() throws InterruptedException
join
(0)
InterruptedException
public static void dumpStack()
Throwable.printStackTrace()
public final void setDaemon(boolean on)
on
true
IllegalThreadStateException
SecurityException
checkAccess()
public final boolean isDaemon()
true
false
setDaemon(boolean)
public final void checkAccess()
SecurityException
SecurityManager.checkAccess(Thread)
public String toString()
public ClassLoader getContextClassLoader()
null
SecurityException
public void setContextClassLoader( ClassLoader cl)
getContextClassLoader
cl
SecurityException
public static boolean holdsLock( Object obj)
assert Thread.holdsLock(obj);
obj
NullPointerException
public StackTraceElement [] getStackTrace()
SecurityException
SecurityManager.checkPermission(java.security.Permission)
RuntimePermission
Throwable.getStackTrace()
public static Map < Thread , StackTraceElement []> getAllStackTraces()
getStackTrace
SecurityException
getStackTrace()
SecurityManager.checkPermission(java.security.Permission)
RuntimePermission
Throwable.getStackTrace()
public long getId()
public Thread. State getState()
public static void setDefaultUncaughtExceptionHandler( Thread. UncaughtExceptionHandler eh)
eh
SecurityException
RuntimePermission
setUncaughtExceptionHandler(java.lang.Thread.UncaughtExceptionHandler)
getUncaughtExceptionHandler()
ThreadGroup.uncaughtException(java.lang.Thread, java.lang.Throwable)
public static Thread. UncaughtExceptionHandler getDefaultUncaughtExceptionHandler()
setDefaultUncaughtExceptionHandler(java.lang.Thread.UncaughtExceptionHandler)
public Thread. UncaughtExceptionHandler getUncaughtExceptionHandler()
public void setUncaughtExceptionHandler( Thread. UncaughtExceptionHandler eh)
eh
SecurityException
setDefaultUncaughtExceptionHandler(java.lang.Thread.UncaughtExceptionHandler)
ThreadGroup.uncaughtException(java.lang.Thread, java.lang.Throwable)