• Post Reply Bookmark Topic Watch Topic
  • New Topic

join() - Thread priority  RSS feed

 
kri shan
Ranch Hand
Posts: 1487
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
join() pause the current thread and give the chance to other waiting threads. Whether waiting threads should have same Thread priority? If waiting thread is lesser Thread priority than current running thread, whether join() pause the current thread?
 
Jim Hoglund
Ranch Hand
Posts: 525
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
join() causes the current thread to wait for the joined thread
to commplete its run() method. Did you intend to ask about
the yield() method?
Jim ... ...
 
kri shan
Ranch Hand
Posts: 1487
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are correct. It's yield(), not join()
 
Vijitha Kumara
Bartender
Posts: 3973
24
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a way of saying the current thread would like to give up CPU time in place of another thread. But you shouldn't depend on the behaviour as it's up to the thread scheduler implementation.
 
vinnu kumar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If we have thread B,that cannot do its work untill thread A has completed,you join B to A.Which means B will not become runnable untill A has finished.
where as yield() is used for turn taking among equal priority threads(but that too is not guaranteed)
 
Henry Wong
author
Sheriff
Posts: 22853
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The yield() method merely passes the hint to the underlying scheduler, that it wishes to give up on its current time slice. Whether anything happens, is dependent on the scheduler.

With certain schedulers, this could mean that a lower priority thread will get a chance to run -- but if it does, it will unlikely run very long, before the scheduler context switches back to the higher priority thread.

Henry

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!