aspose file tools*
The moose likes Threads and Synchronization and the fly likes Is my thread usage technique practical? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Is my thread usage technique practical?" Watch "Is my thread usage technique practical?" New topic
Author

Is my thread usage technique practical?

Charles Mulloy
Ranch Hand

Joined: Oct 25, 2009
Posts: 30
I've read the article here and found it to work wonders. Though I need to know if it is practical.

One technique that I've developed if that if I'm going to make multiple JPanels is that I'll use a different class for each one and confine methods for that panel in that class as well, simply for the sake of organization. But when I see notifyAll(), I think "Oh crap, every single thread in waiting is going to go off when the program hits that line." Does notifyAll() signal all the threads in the program or would it be confined to the class it's written? I want to put in more functions, but not if they're all trigger simultaneously with one button click. Also I need to know if I'm on the right track, or if I need to find another technique.

My JButtons normally look like this:

pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
The API will answer this for you: http://java.sun.com/javase/6/docs/api/java/lang/Object.html#notifyAll%28%29

Wakes up all threads that are waiting on this object's monitor. A thread waits on an object's monitor by calling one of the wait methods.

Though I have to admit that I haven't written such code in a Swing application. You're locking background threads hopefully.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is my thread usage technique practical?
 
Similar Threads
notify() and notifyAll()
Took essay exam yesterday (4th May 2010)
Threads MindQ 41
Locking - Notification issues
One lock call per client :-)because they don�t deserve more:-) URLyBird 1.1.3