[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to debug a deadlock in the java program?

Posted on 2004-09-01
8
Medium Priority
?
699 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: 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!

 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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…
This video teaches viewers about errors in exception handling.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

649 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