Question: What are the Java Thread Methods?
Answer: Java Thread class
Java provides Thread class to achieve thread programming. Thread class provides constructors and methods to create and perform operations on a thread. Thread class extends Object class and implements Runnable interface.
Java Thread Methods
Modifier and Type: void
Method: start()
Description: It is used to start the execution of the thread.

Modifier and Type: void
Method: run()
Description: It is used to do an action for a thread.

Modifier and Type:  static void
Method: sleep()
Description: It sleeps a thread for the specified amount of time.

Modifier and Type: static Thread
Method: currentThread()
Description: It returns a reference to the currently executing thread object.

Modifier and Type:  void
Method: join()
Description: It waits for a thread to die.



Modifier and Type: int
Method: getPriority()
Description: It returns the priority of the thread.

Modifier and Type: void
Method:  setPriority()
Description: It changes the priority of the thread.

Modifier and Type: String
Method: getName()
Description: It returns the name of the thread.

Modifier and Type:  void
Method:  setName()
Description: It changes the name of the thread.

Modifier and Type:  long
Method:  getId()
Description: It returns the id of the thread.

Modifier and Type:  boolean
Method: isAlive()
Description:  It tests if the thread is alive.



Modifier and Type: static void
Method:  yield()
Description: It causes the currently executing thread object to pause and allow other threads to execute temporarily.

Modifier and Type: void
Method: suspend()
Description: It is used to suspend the thread.

Modifier and Type: void
Method:  resume()
Description: It is used to resume the suspended thread.

Modifier and Type: void
Method: stop()
Description: It is used to stop the thread.

Modifier and Type: void
Method:  destroy()
Description: It is used to destroy the thread group and all of its subgroups.

Modifier and Type:  boolean
Method:  isDaemon()
Description: It tests if the thread is a daemon thread.




Modifier and Type: void
Method: setDaemon()
Description: It marks the thread as daemon or user thread.

Modifier and Type: void
Method: interrupt()
Description: It interrupts the thread.


Modifier and Type: boolean
Method: isinterrupted()
Description: It tests whether the thread has been interrupted.

Modifier and Type: static boolean
Method: interrupted()
Description: It tests whether the current thread has been interrupted.

Modifier and Type: static int
Method: checkAccess()
Description: It determines if the currently running thread has permission to modify the thread.

Modifier and Type: static boolean
Method: holdLock()
Description: It returns true if and only if the current thread holds the monitor lock on the specified object.

Modifier and Type: static void
Method: dumpStack()
Description: It is used to print a stack trace of the current thread to the standard error stream.

Modifier and Type: StackTraceElement[]
Method: getStackTrace()
Description: It returns an array of stack trace elements representing the stack dump of the thread.

Modifier and Type: static int
Method: enumerate()
Description: It is used to copy every active thread's thread group and its subgroup into the specified array.

Modifier and Type: Thread.State
Method: getState()
Description: It is used to return the state of the thread.

Modifier and Type: ThreadGroup
Method: getThreadGroup()
Description: It is used to return the thread group to which this thread belongs

Modifier and Type: String
Method: toString()
Description: It is used to return a string representation of this thread, including the thread's name, priority, and thread group.

Modifier and Type: void
Method: notify()
Description: It is used to give the notification for only one thread which is waiting for a particular object.

Modifier and Type: void
Method: notifyAll()
Description: It is used to give the notification to all waiting threads of a particular object.

Modifier and Type: void
Method: setContextClassLoader()
Description: It sets the context ClassLoader for the Thread.

Modifier and Type: ClassLoader
Method: getContextClassLoader()
Description: It returns the context ClassLoader for the thread.

Modifier and Type: static Thread.UncaughtExceptionHandler
Method: getDefaultUncaughtExceptionHandler()
Description: It returns the default handler invoked when a thread abruptly terminates due to an uncaught exception.

Modifier and Type: static void
Method: setDefaultUncaughtExceptionHandler()
Description: It sets the default handler invoked when a thread abruptly terminates due to an uncaught exception.