Here's a piece of Java code,
public class Z {
public static void Main (string[] args)
{
New Z ();
}
Private Z ()
{
Z A1=this;
Z A2=this;
Synchronized (A1)
{
try {
A2.wait ();
System.out.println ("Done Waiting");
}
catch (Interruptedexception e)
{
System.out.println ("Interruptedexception");
}
catch (Exception e)
{
System.out.println ("Exception");
}
Finally
{
System.out.println ("finally");
}
}
System.out.println ("All done");
}
}
Run after compiling
Java Z
Without any output, the program will not end.
PS looked at the state, found that the state is sl+,
In Linux, the status is as follows:
D non-disruptive uninterruptible sleep (usually IO)
R is running, or the process in the queue
S is in a dormant state
T stop or be traced
Z Zombie Process
W enters memory Exchange (invalid starting from kernel 2.6)
X dead Process
< high-priority
N Low Priority
L Some pages are locked into memory
s contains child processes
+ Group of processes in the background
L multi-threading, cloning threads
Based on the above information, it is known that it is in hibernation, multithreading, and is a background process.
We know that in Java,
Wait (): Leave the thread in the waiting state. The thread will then release the lock. Coexist into the thread pool.
Notify (): Usually wakes up the first one in the thread pool.
Notifyall (): Wakes all waiting threads in the thread pool.
So while waiting, this thread sleeps and waits for other threads to notify, so it's dormant.
Reprint please indicate the source:
Original: http://blog.csdn.net/hongchangfirst/article/details/8650628
Author: Hongchangfirst