If a thread encounters
aThread.join();
waits for aThread to die before executing the instruction after aThread.join();
In the
API for Thread you can check that there is no such method. However you can synchronize a block of code within a method with:
.
.
.
synchronized(lockObject) {
//block to execute only for the tread owner of
//lockObject
}
.
.
.
A thread becomes owner of lockObject via executing a piece of code guarded by a synchronized command on lockObject, like the previous one, but it can only do it if the lockObject is not already grabbed. Because this would mean that a thread is already executing as piece of code that can not be executed simoultaneasly with a piece of code guarded by the same lock.
Did I messed up the thing?