Thread Class Methods Flashcards Preview

OCP > Thread Class Methods > Flashcards

Flashcards in Thread Class Methods Deck (10):
1

Returns reference to the current thread.

Thread.currentThread()

2

Returns the name of the current thread.

String getName()

3

Returns the priority value of the current thread.

int getPriority()

4

The current thread invoking this method on another thread waits until the other thread dies. Overloaded to be able to give the timeout in milliseconds or milliseconds and nanoseconds.

void join()

5

Once you start a thread using the start() method, this method will be called when the thread is ready to execute.

void run()

6

Changes the name of the thread to the given name in the argument.

void setName(String name)

7

Sets the priority of the thread to the given argument value.

void setPriority(int priorityValue)

8

Makes the current thread sleep for given milliseconds or milliseconds and nanoseconds.

Thread.sleep(long milliseconds, int nanoseconds)

9

Starts the thread; JVM calls the run() method of the thread.

void start()

10

Overridden method of Object that returns the string representation of the thread. Has the threads name, priority, and group.

String toString()