• 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

Thread.sleep(15000) inside actionlistener

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I can't seem to figure out how to refresh my serverstatusdialog with a message that says shutting down in 15 seconds and then sleeping 15 and doing a system.exit(-1).

Basically my SSD has a shutdown action called when shutdown is pressed. This action create a confirm dialog with the ok of the confirm i unbind the rmi server, set a flag to prevent more requests, and then set the text value of the textfield on the SSD to "shutting down delaying 15 seconds" and finally Thread.sleep(15000).

What happens is the SSD freezes and does not update with the text, 15 seconds passes and the application quits.

Any suggestions?

Thanks.
 
Ranch Hand
Posts: 1033
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't use sleep. The best way to schedule an event is to use a timer. If you are in a Swing GUI, you can use the javax.swing.Timer class, which is much easier to use than the java.util.Timer. The Swing timer causes an event to be fired when the time value expires.
 
Mike Grandmaison
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah that worked well.

Thanks for the tip!
reply
    Bookmark Topic Watch Topic
  • New Topic