Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Thread execution

 
Roger Fed
Ranch Hand
Posts: 82
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
I've developed this class that creates two threads hello,count

this is the output
1
Hello
Hello
2
Hello
3
4
Hello
Hello
5

I've only one Question:

The hello thread is started before the count thread but the count thread executed first............how???
 
Hauke Ingmar Schmidt
Rancher
Posts: 436
2
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's exactly how threads work: You don't know how they are scheduled. If you want to control how they play together you need to do some synchronization via locks, semaphores or wait & notify.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!