Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why it shows Toast message before ends the runnable method

 
sam liya
Ranch Hand
Posts: 1243
  • 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: 1243
  • 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: 42969
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: 1243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bolsens ,all.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic