Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is my thread usage technique practical?

 
Charles Mulloy
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic