aspose file tools
The moose likes Threads and Synchronization and the fly likes Is the following program thread safe ?. Please help... Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "Is the following program thread safe ?. Please help..." Watch "Is the following program thread safe ?. Please help..." New topic
Author

Is the following program thread safe ?. Please help...

Steven Rodeo
Ranch Hand

Joined: Mar 06, 2008
Posts: 72
I've been trying to analyze the following class and see that there is always a dead lock in the following call to hello.

Yep this is a multithreaded application.

Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2896
    
    1

Have you thought about synchronizing the "hello" method ??


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Ray Hsieh
Ranch Hand

Joined: Sep 20, 2000
Posts: 59
Well, to be sure, create a thread dump. If it's on Windows you press Ctrl + Break. For example, if we have an obvious deadlock like this:



Then pressing Ctrl + Break on Windows gives you a bunch of text that highlights the deadlock like this:

... a lot of text ...

Found one Java-level deadlock:
=============================
"Thread-1":
waiting to lock monitor 0x02a807cc (object 0x2405edb0, a java.lang.Object),
which is held by "Thread-0"
"Thread-0":
waiting to lock monitor 0x02a82094 (object 0x2405edb8, a java.lang.Object),
which is held by "Thread-1"

... a lot more text ...

If you name your threads properly, you can see that this info can be very useful.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Is the following program thread safe ?. Please help...
 
Similar Threads
interactive filtered JFileChooser
sax parser with cdata
ServletContext and properties file
Class.forName Thread Safe ?
How to get open or save dialog in struts.