-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCh13_74_LifecycleOfThread.java
More file actions
27 lines (21 loc) · 1.2 KB
/
Ch13_74_LifecycleOfThread.java
File metadata and controls
27 lines (21 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
public class Ch13_74_LifecycleOfThread {
public static void main(String[] args) {
System.out.println();
/* Just like humans - thread also has its own life cycle -
It include stages:
1. NEW (Get)
2. RUNNABLE (Set)
3. RUNNING (Go)
4. NON-RUNNABLE
5. TERMINATED (Finish) */
/* In brief -
New - It refers to the stage of creating objects but not executing it. (i.e. Start() method is not called)
** as soon as start() is called it chooses thread, which are created in the new stage.
Runnable - It gives the thread a position such that the thread scheduler chooses the thread to execute.
Running - After a thread is selected it comes in stage of running.
Non-Runnable - These Thread are runnable but wait for the correct instance ( For ex. While accessing a site a pdf viewer only works when we click on it)
Termination - When the run() method exit it is called terminated. */
/* ** To Understand better compare it how an athletics race is done that is
NEW = GET || RUNNABLE = SET || RUNNING = GO || NOT-ELIGIBLE = NON-RUNNABLE || FINISH = TERMINATED */
}
}