Linux ps state sl+是什麼意思

來源:互聯網
上載者:User

下面這是一段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,所以就處於休眠狀態了。

轉載請註明出處:

原文:http://blog.csdn.net/hongchangfirst/article/details/8650628

作者:hongchangfirst



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.