File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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

Joined: Feb 23, 2007
Posts: 1561
The API will answer this for you:

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:
subject: Is my thread usage technique practical?
jQuery in Action, 3rd edition