Java Multithreading, Concurrency, and Parallelism — Part 3
4 min readJul 6, 2021
Life Cycle of a thread with Methods in Thread Class
For managing threads in java, we have many static and instance methods in the Thread
class. We can use these methods for creating, starting, pausing, and stopping threads.
Static Methods
static int activeCount()
static Thread currentThread()
static void dumpStack()
static boolean interrupted()
static void sleep()
static void yield()
Instance Methods
void start()
long getId()
String getName()
int getPriority()
void interrupt()
boolean isInterrupted()
boolean isAlive()
void join()
String toString()
This is not the complete list and we will not even cover all of the above. There are other methods but we don’t really need them unless we build some tiny multithreading frameworks ourselves.
Here in this article, we will discuss the methods related to the lifecycle of threads in Java:start()
and sleep()
. We will also discuss some of the states in the thread’s lifecycle.