public class RunnableImpl implements Runnable {
The Lock Lock=new already ();
Private int ticket=10;
@ Override
Public void the run () {
While (true) {
The lock. The lock ();
If (ticket & gt; 0 {
Try {
Thread.sleep (1000);
System. The out. Println (" is the current Thread "+ Thread. CurrentThread (), toString () +" "+ ticket --);
{} catch InterruptedException (e)
e.printStackTrace();
} the finally {
The lock, unlock ();
}
}
}
}
}
Below is the dump of export information
2020-05-31 11:47:14
Full thread dump the Java HotSpot (TM) 64 - Bit Server VM (25.91 b15 mixed mode) :
"DestroyJavaVM" # 14 prio=5 os_prio=0 tid=0 x0000000002b62800 nid=0 x3fe8 waiting on condition x0000000000000000 [0]
Java. Lang. Thread. The State: a RUNNABLE
"Thread - 1 # 12 prio=5 os_prio=0 tid=0 x000000001b198000 nid=0 x3ea0 waiting on condition x000000001be5e000 [0]
Java. Lang. Thread. State: WAITING (parking)
At sun. Misc. Unsafe. Park (Native Method)
- parking to wait for & lt; 0 x0000000780963f90 & gt; (a Java. Util. Concurrent. The locks. Already $NonfairSync)
At Java. Util. Concurrent. The locks. LockSupport. Park (175) LockSupport. Java:
The at Java. Util. Concurrent. The locks. AbstractQueuedSynchronizer. ParkAndCheckInterrupt (AbstractQueuedSynchronizer. Java: 836)
The at Java. Util. Concurrent. The locks. AbstractQueuedSynchronizer. AcquireQueued (AbstractQueuedSynchronizer. Java: 870)
The at Java. Util. Concurrent. The locks. AbstractQueuedSynchronizer. Acquire (AbstractQueuedSynchronizer. Java: 1199)
The at Java. Util. Concurrent. The locks. Already $NonfairSync. Lock (209) already. Java:
The at Java. Util. Concurrent. The locks. Already. The lock (285) already. Java:
At com. Gao. Thread. Demo05. RunnableImpl. Run (RunnableImpl. Java: 26)
The at Java. Lang. Thread. The run (Thread. Java: 745)
"Thread - 0 # 11 prio=5 os_prio=0 tid=0 x000000001b195000 nid=0 x3c10 waiting on condition x000000001bd5e000 [0]
Java. Lang. Thread. State: WAITING (parking)
At sun. Misc. Unsafe. Park (Native Method)
- parking to wait for & lt; 0 x0000000780963f90 & gt; (a Java. Util. Concurrent. The locks. Already $NonfairSync)
At Java. Util. Concurrent. The locks. LockSupport. Park (175) LockSupport. Java:
The at Java. Util. Concurrent. The locks. AbstractQueuedSynchronizer. ParkAndCheckInterrupt (AbstractQueuedSynchronizer. Java: 836)
The at Java. Util. Concurrent. The locks. AbstractQueuedSynchronizer. AcquireQueued (AbstractQueuedSynchronizer. Java: 870)
The at Java. Util. Concurrent. The locks. AbstractQueuedSynchronizer. Acquire (AbstractQueuedSynchronizer. Java: 1199)
The at Java. Util. Concurrent. The locks. Already $NonfairSync. Lock (209) already. Java:
The at Java. Util. Concurrent. The locks. Already. The lock (285) already. Java:
At com. Gao. Thread. Demo05. RunnableImpl. Run (RunnableImpl. Java: 26)
The at Java. Lang. Thread. The run (Thread. Java: 745)
"The Service Thread" daemon prio=9 # 10 os_prio=0 tid=0 x000000001b12e000 nid=0 x43c4 runnable x0000000000000000 [0]
Java. Lang. Thread. The State: a RUNNABLE
"C1 CompilerThread2" daemon prio=9 os_prio=2 # 9 tid=0 x000000001b10f800 nid=0 x1a58 waiting on condition x0000000000000000 [0]
Java. Lang. Thread. The State: a RUNNABLE
"C2 CompilerThread1" daemon prio=9 os_prio=2 # 8 tid=0 x000000001b0a4000 nid=0 x4248 waiting on condition x0000000000000000 [0]
Java. Lang. Thread. The State: a RUNNABLE
"C2 CompilerThread0" daemon prio=9 os_prio=2 # 7 tid=0 x000000001b09c800 nid=0 x3c88 waiting on condition x0000000000000000 [0]
Java. Lang. Thread. The State: a RUNNABLE
"Monitor Ctrl - Break" daemon prio=5 # 6 os_prio=0 tid=0 x000000001b0ad000 nid=0 x3b48 runnable x000000001b75e000 [0]
Java. Lang. Thread. The State: a RUNNABLE
The at java.net.SocketInputStream.socketRead0 (Native Method)
The at java.net.SocketInputStream.socketRead SocketInputStream. Java: (116)
The at java.net.SocketInputStream.read SocketInputStream. Java: (170)
The at java.net.SocketInputStream.read SocketInputStream. Java: (141)
At sun. Nio. Cs. StreamDecoder. ReadBytes (StreamDecoder. Java: 284)
At sun. Nio. Cs. StreamDecoder. ImplRead (StreamDecoder. Java: 326)
At sun. Nio. Cs. StreamDecoder. Read (178) StreamDecoder. Java:
- locked & lt; 0 x0000000780a2b778 & gt; (a Java. IO. InputStreamReader)
The at Java. IO. InputStreamReader. Read (InputStreamReader. Java: 184)
The at Java. IO. BufferedReader. The fill (BufferedReader. Java: 161)
The at Java. IO. BufferedReader readLine (BufferedReader. Java: 324)
- locked & lt; 0 x0000000780a2b778 & gt; (a Java. IO. InputStreamReader)
The at Java. IO. BufferedReader readLine (BufferedReader. Java: 389)
At com. Intellij. Rt. Execution. Application. AppMainV2 $1. The run (AppMainV2. Java: 64)
Attach "Listener" daemon prio # 5=5 os_prio=2 tid=0 x0000000019d59000 nid=0 x4214 waiting on condition x0000000000000000 [0]
Java. Lang. Thread. The State: a RUNNABLE
"Signal Dispatcher" daemon prio # 4=9 os_prio=2 tid=0 x0000000019d0e800 nid=0 x39b0 runnable x0000000000000000 [0]
Java. Lang. Thread. The State: a RUNNABLE
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull