• 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

swing+threads

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I launch a swing application, the GUI runs in a separate thread. Why should I construct my own Runnable and call ...InvokeLater() - as recommended in the Sun Tutorial ?
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The recommendation is given in the note that follows the first paragraph under the header "The Event-Dispatching Thread" on How to Use Threads. If components begin sending events to event listeners before the initial state of your app is complete it can cause trouble. This often happens with ComponentListeners and MouseMotionListeners. It can happen with listeners being added before components have been initialized during construction and with certain uses of threads. There are a lot of ways to get into trouble like this so it's easier for the designers to say "always do this and you'll be safe" than to try to explain everything that could possibly go wrong. Careful design is the alternative.
 
Evacuate the building! Here, take this tiny ad with you:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic