Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to debug a deadlock in the java program?

Posted on 2004-09-01
8
Medium Priority
?
701 Views
Last Modified: 2012-06-21
Hi, everyone:

I have encountered a deadlock in the java program. And I must debug it and correct the deadlock.

The program uses a lot of threads and I have checked the jvm output by clicking "ctrl + \" (dump as below). It shows a deadlock in the program. Could anyone give me some ideas on how to debug the multithreaded program written in java? Is there any tools to help me debug the multithread program?

Thanks.

/----jvm dump----/
...omit something
Found one Java-level deadlock:
=============================
"Thread-0":
  waiting to lock monitor 0x000bee70 (object 0xf1b9e878, a com.lucent.umts.gui.UmtsFrame),
  which is held by "AWT-EventQueue-0"
"AWT-EventQueue-0":
  waiting to lock monitor 0x000bee38 (object 0xf1bfb558, a javax.swing.RepaintManager),
  which is held by "Thread-0"
/----dump end---/
0
Comment
Question by:yangsun
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 92

Accepted Solution

by:
objects earned 150 total points
ID: 11950493
check that you aren't accessing your gui, from a thread other than the event dispatch thread
0
 
LVL 35

Expert Comment

by:girionis
ID: 11950537
Are you using any wait()/notify()? Can you post some sample code? Check the thread that waits. It is possible that you try to notify the thread from the same thread but due to being waiting it can't do anything.
0
 
LVL 35

Expert Comment

by:girionis
ID: 11950542
> Is there any tools to help me debug the multithread program?

Have a look here: http://forum.java.sun.com/thread.jsp?forum=47&thread=517540&tstart=45&trange=15
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 13

Expert Comment

by:Webstorm
ID: 11952207
Hi yangsun,

You can resolve the deadlock : Thread-0 must get all locks in the same order as AWT-EventQueue get them.

0
 
LVL 1

Expert Comment

by:talvio
ID: 11956285
Hi,

hmm, maybe I am wrong here, but without knowing better that looks to me like you might be blocking the AWT thread by using wait(). I think you should not -probably ever- block the AWT thread, because that will always make your GUI unresponsive. Blocking AWT thread is probably caused by calling wait() somewhere in a paint() method or key event listener methods. Those should be easy to scan. If such a call is found, remove it and find another solution for that.

-jT
0
 

Author Comment

by:yangsun
ID: 11963324
Thanks for your helps. I am a newbie to java multithreading. So I have to read some background materials about java multithreading these days.
I will accept one solution after my understanding the basic concept. Thanks.
0
 
LVL 92

Expert Comment

by:objects
ID: 11969015
Here's some background on Swing and threads, basically Swing is single threaded and does not support being accessed by more than one thread:
http://java.sun.com/products/jfc/tsc/articles/threads/threads1.html
0
 

Author Comment

by:yangsun
ID: 11993385
Thanks. I have fixed the problem.
It is caused by a gui-operation outside the event queue.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month20 days, 16 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question