This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

delay in setVisible( true )

 
Mike Gershman
Ranch Hand
Posts: 1272
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to simulate dice rolling as follows:

You Rolled:

< 2 seconds pass >

You Rolled: 3

< 1 more second passes >

You Rolled: 3 + 4 = 7

Instead, the whole line displays at once after 3 seconds. Please tell me what is wrong.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you call rollDice() from an event handler, then the event thread -- which is also responsible for painting the screen -- is blocked as long as rollDice() runs. Nothing can change on the screen until the event thread becomes free.

For this reason, you should never do anything that takes longer than a few milliseconds on the event thread. If you need to start a long-running operation from the GUI, always do it by spawning a new thread -- i.e.,

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic