• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Is my thread usage technique practical?

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:

 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You ought to ventilate your mind and let the cobwebs out of it. Use this cup to catch the tiny ads:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic