歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Linux ps state sl+是什麼意思

Linux ps state sl+是什麼意思

日期:2017/3/1 9:58:59   编辑:Linux編程

下面這是一段java代碼,

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");
}

}

編譯後運行

java Z

沒有任何輸出,程序也不會結束。

ps看了一下狀態,發現狀態是sl+,

在Linux中,狀態如下:

D 不可中斷 Uninterruptible sleep (usually IO)
R 正在運行,或在隊列中的進程
S 處於休眠狀態
T 停止或被追蹤
Z 僵屍進程
W 進入內存交換(從內核2.6開始無效)
X 死掉的進程

< 高優先級
N 低優先級
L 有些頁被鎖進內存
s 包含子進程
+ 位於後台的進程組
l 多線程,克隆線程


根據以上信息,得知其處於休眠狀態,多線程,且是後台進程。

我們知道Java中,

wait():讓線程處於等待狀態。這時線程會釋放鎖。並存入到了線程池中。
notify():通常喚醒線程池中的第一個。
notifyAll():將線程池中的所有等待線程都喚醒。

所以在wait的時候,此線程休眠等待其他線程notify,所以就處於休眠狀態了。

Copyright © Linux教程網 All Rights Reserved