This week's giveaway is in the Threads forum.
We're giving away four copies of Java Concurrency Live Lessons and have Doug Schmidt on-line!
See this thread for details.
Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

why it shows Toast message before ends the runnable method  RSS feed

 
sam liya
Ranch Hand
Posts: 1246
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Below is my code.when i click the button it runs the progress dialog,but before end the progress dialog it shows the Toast message.how it happens?


 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is a thread and what is its purpose?
 
sam liya
Ranch Hand
Posts: 1246
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i need to test progressdialog example.So this is for it.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You misunderstood. new Thread().start() does not do what you seem to think it does. So:
What is a thread and what is its purpose?
 
Joris Bolsens
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It does that because you are displaying the toast on a different thread, it displays it as soon as the main thread has finished creating the new thread.
The point of a threads is to be able to do multiple things at once. So even if you tell that thread to wait, the main thread just keeps going.
 
sam liya
Ranch Hand
Posts: 1246
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bolsens ,all.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!