This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with output of The Code  RSS feed

 
buntha Choudhary
Ranch Hand
Posts: 136
Android Eclipse IDE Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the following code , the ds.g() is getting called first after that the thread named ds.f() is being started but according to the code, the thread should get called first.



 
Henry Wong
author
Sheriff
Posts: 23275
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the following code , the ds.g() is getting called first after that the thread named ds.f() is being started but according to the code, the thread should get called first.


Not true. Once the new thread is started, it is now running independent of the main thread. So, whether the f() method or the g() method gets called first depends on the processor, the OS, priority, etc. These two threads are now racing each other, and on some OSes, f() will be called first, on others, g() will execute first.

Henry
 
buntha Choudhary
Ranch Hand
Posts: 136
Android Eclipse IDE Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!