Below is 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 ");
}
}
Compile and run
Java Z
Without any output, the program will not end.
PS looked at the status and found that the status is SL +,
In Linux, the status is as follows:
D. uninterruptible sleep (usually Io) cannot be interrupted)
R is running or a process in the queue
S is in sleep state
T stop or be tracked
Z botnets
W enters the memory switch (it is invalid from kernel 2.6)
X Dead Process
<High priority
N Low priority
L some pages are locked into memory
S contains sub-Processes
+ Process group in the background
L multi-thread, clone thread
Based on the above information, we know that it is in sleep state, multithreading, and background process.
We know that in Java,
Wait (): puts the thread in the waiting state. The thread releases the lock. And stored in the thread pool.
Y (): it is usually used to wake up the first thread in the thread pool.
Yyall (): wake up all the waiting threads in the thread pool.
So when wait is running, this thread waits for other threads to sleep, so it is in sleep state.
Reprinted please indicate the source:
Original article: http://blog.csdn.net/hongchangfirst/article/details/8650628
Author: hongchangfirst