2014年4月30日星期三

Java_013:TIMED_WAITING (sleeping)线程例子 (摘录+整理)

1. 代码
public class SleepThread {
    public static void main(final String[] args) throws Exception {
        Thread.sleep(200000L);
    }

}

2. 线程main的thread dump
线程main的状态是wait on condiction:TIMED_WAITING(sleeping)
"main" prio=5 tid=0x00007fddfb800000 nid=0x1903 waiting on condition [0x00000001063e8000]
   java.lang.Thread.State: TIMED_WAITING (sleeping)
at java.lang.Thread.sleep(Native Method)
at SleepThread.main(SleepThread.java:3)

原因解释:
因为main线程一直在睡大觉,所以睡醒之前,状态一直是TIMED_WAITING(sleeping)。

没有评论: