|
Threads
API
for Thread class
Constructors:
-
Thread ()
-
Thread (Runnable obj, String name)
-
Thread (Runnable obj)
-
Thread (String name)
-
Thread (ThreadGroup tg, Runnable obj)
-
Thread (ThreadGroup tg, Runnable obj,
String name)
-
Thread (ThreadGroup tg, String name)
ThreadGroup versions
throw SecurityException if the current thread cannot
create a thread in the specified group.
static methods:
Returns the current
number of active threads in this thread's thread
group.
Returns a reference to
the currently executing thread object.
Tests whether the
current thread has been interrupted. The interrupted
status of the thread is cleared by this method. In
other words, if this method were to be called twice in
succession, the second call would return false (unless
the current thread were interrupted again, after the
first call had cleared its interrupted status and
before the second call had examined it).
-
void sleep (long millis)
throws
InterruptedException
-
void sleep (long millis, int ns)
throws
InterruptedException
sleep () causes the
currently executing thread to sleep (temporarily cease
execution) for the specified number of milliseconds
(and ns nanoseconds if specified). The thread does not
lose ownership of any monitors. Throws
InterruptedException if another thread has interrupted
the current thread. The interrupted status of the
current thread is cleared when this exception is
thrown.
Causes the currently
executing thread object to temporarily pause and allow
other threads to execute.
Instance methods:
-
void checkAccess ()
-
void destroy ()
Destroys this thread,
without any cleanup. Any monitors it has locked remain
locked. (This method is not implemented.)
-
String getName ()
-
void setName (String name)
-
int getPriority ()
-
void setPriority (int priority)
-
ThreadGroup getThreadGroup ()
-
void interrupt ()
-
boolean
isAlive ()
-
boolean
isDaemon ()
-
boolean
isInterrupted ()
Tests whether this
thread has been interrupted. The interrupted status
of the thread is unaffected by this method.
-
void join ()
-
void join (long millis)
Waits at most millis
milliseconds for this thread to die. A timeout of 0
means to wait forever. Throws InterruptedException if
another thread has interrupted the current thread. The
interrupted of the current thread is cleared when this
exception is thrown.
If this thread was
constructed using a separate Runnable object, then
that Runnable object’s run method is called;
otherwise, this method does nothing and returns.
Marks this thread as
either a daemon or a user thread. The JVM exits when
the only threads running are all daemon threads. This
method must be called before the thread is started.
Causes this thread to begin
execution; the JVM 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). Throws
IllegalThreadStateException if the thread was already
started.
|