In this tutorial, we will learn about Thread class methods. In the last tutorial, we already saw two thread class methods run() and start() method. There are a lot of other methods in Thread class. Check this following list.
| Method | Description |
|---|---|
| public void start() | This method is used to start the execution of the thread. |
| public void run() | This method is used to describe the action in the thread. |
| public final void setName(String name) | This method is used to set the name of the thread. |
| public final void setPriority(int priority) | This method is used to set the priority of the thread. |
| public final void join(long milliseconds) | This method is used to block the current thread for specified milliseconds until another thread completes its execution or specified milliseconds passed |
| public void interrupt() | This method is used to interrupt a thread. |
| public void stop() | This method is used to stop a thread. |
| public void suspend() | This method is used to suspend a thread. |
| public void resume() | This method is used to resume the suspended thread. |
| public final boolean isAlive() | This method is used to check whether a thread is alive or not. |
| public static void yield() | This method is used to block currently running thread and allow other threads with the same property to run temporarily. |
| public static void sleep(long milliseconds) | This is used to block a thread for specific milliseconds. |
| public static boolean holdsLock(Object x) | This method will return true if the current thread holds the lock on the given Object. |
| public static Thread currentThread() | This method returns the reference of currently running thread. |
| public static void dumpStack() | This method prints the stack trace of currently running thread. |
| public void destroy() | This method is used to destroy the thread group. |
Parvesh Sandila is a results-driven tech professional with 8+ years of experience in web and mobile development, leadership, and emerging technologies.
After completing his Master’s in Computer Applications (MCA), he began his journey as a programming mentor, guiding 100+ students and helping them build strong foundations in coding. In 2019, he founded Owlbuddy.com, a platform dedicated to providing free, high-quality programming tutorials for aspiring developers.
He then transitioned into a full-time programmer, where his hands-on expertise and problem-solving skills led him to grow into a Team Lead and Technical Project Manager, successfully delivering scalable web and mobile solutions. Today, he works with advanced technologies such as AI systems, RAG architectures, and modern digital solutions, while also collaborating through a strategic partnership with Technobae (UK) to build next-generation products.
