Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Question regarding threads  RSS feed

 
Sajee Joseph
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Suppose i have 3 threads t1, t2, t3.
To get a multithreaded behavioyur can i just invoke the start() methods on each of the threads one after the other ( assuming i have written code in the run method to do the necessary task).
Or do i have to esnuer that each thread sleeps for a while so that other threads will take control and not get starved.
In other words is it essentila that each thread sleep for a while to geta multithreaded behaviour?

Regards,
Saj
 
Bajji Pat
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sajee,

As per my knowledge it is upto the underlying implementation (OS) to give the threads CPU time. It might be "Round robin scheduling" or some other scheduling mechanism. Even if you make the threads sleep, it does guarantee that they get the CPU time immediately, they only return to the runnable state from where it is upto the underlying scheduling algorithm to give it a shot at CPU time.

Hope this clarifies.
Regards
Bajji Pat
[ April 12, 2005: Message edited by: Bajji Pat ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!