| Author |
join() - Thread priority
|
kri shan
Ranch Hand
Joined: Apr 08, 2004
Posts: 1300
|
|
|
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
Joined: Jan 09, 2008
Posts: 525
|
|
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 ... ...
|
BEE MBA PMP SCJP-6
|
 |
kri shan
Ranch Hand
Joined: Apr 08, 2004
Posts: 1300
|
|
|
You are correct. It's yield(), not join()
|
 |
Vijitha Kumara
Bartender
Joined: Mar 24, 2008
Posts: 3670
|
|
|
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.
|
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
|
 |
vinnu kumar
Greenhorn
Joined: Sep 10, 2007
Posts: 12
|
|
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
Joined: Sep 28, 2004
Posts: 16695
|
|
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
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
 |
|
|
subject: join() - Thread priority
|
|
|