O'Reilly logo

Java 9 Concurrency Cookbook - Second Edition by Javier Fernández González

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How it works...

The following screenshot shows the result of the analysis by FindBugs:

The analysis has detected the following two potential bugs in the application:

  • One of the bugs is detected in the run() method of the Task class. If an InterruptedExeption exception is thrown, the task doesn't free the lock because it won't execute the unlock() method. This will probably cause a deadlock situation in the application.
  • The other bug is detected in the main() method of the Main class because you called the run() method of a thread directly, not the start() method to begin the execution of the thread.

If you double-click on one of the two ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required