Solved

How to debug a deadlock in the java program?

Posted on 2004-09-01
8
689 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 50 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
 
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This video teaches viewers about errors in exception handling.

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now