Deadlock check

Can someone tell me how I can find out how many threads are in deadlock mode in a multi-threaded Java application? How to find out the list of blocked threads?

I heard about Thread Dump and Stack Traces, but I don't know how to implement it.

  • I also want to know what new features were introduced in Java 5 for Threading?

Please let me know with your comments and suggestions.

+3
source share
4 answers

The method of obtaining stream dumps:

  • ctrl-break (Windows) or ctrl- \, possibly ctrl-4 kill -3on Linux / UNIX
  • jstackand your process id (use jps)
  • jconsole or visualvm
  • just about any debugger

J2SE 5.0 ( 2004 , ):

  • java.util.concurrent
  • Java.
+7

kill -3

+2

ThreadMXBean findMonitorDeadlockedThreads(), . Windows, Ctrl + Break, .

Java, concurrency, , Java 5, , Compare-And-Set (CAS) . , , concurrency . , :

  • , .
  • concurrency (, , )

, Java 5 concurrency.

+1

Java 5, , Java Concurrency ( Java 5 Concurrency). .

:

  • - Executor - , , . , , ( Swing), , Executor . , , , .
  • Concurrent Collections - , Queue BlockingQueue, Map, List Queue.
  • - ( ), . , java.util.concurrent.atomic, , ( ), , .
  • - , , , , , .
  • . Java , . java.util.concurrent.locks , , - , , , , , .
  • Nanosecond granularity - the System.nanoTime method allows you to access a time source based on nanosecond granularity for relative time measurements and methods that take timeouts (such as BlockingQueue.offer, BlockingQueue.poll, Lock.tryLock, Condition.await and Thread.sleep ) can take timeout values ​​in nanoseconds. The actual accuracy of System.nanoTime is platform dependent.
0
source

Source: https://habr.com/ru/post/1708674/


All Articles