private class LockTest.RendezvousUser extends LockTest.LockUser
This type of thread is used to check that locks can be taken simultaneously, or one lock can be taken for shared access by two threads. Rendezvous threads are created two at a time. The first thread takes a lock and waits for the second to do the same. The second thread wakes the first, and then both threads release the lock and exit. If the second thread is unable to take the lock while the first thread still holds it, the test will fail due to timeout, as the second thread is blocked indefinitely.
Constructor and Description |
---|
RendezvousUser(Path path,
boolean exclusive)
Creates a rendezvous thread.
|
Modifier and Type | Method and Description |
---|---|
protected void |
locked()
Causes the two threads to rendezvous.
|
protected void |
released()
Increments the number of threads that have exited.
|
run, started
RendezvousUser(Path path, boolean exclusive)
path
- Path to be locked by this thread.exclusive
- Whether or not the path is to be locked for
exclusive access.protected void locked()
If this thread turns out to be the first to take the lock, it waits for the other thread to wake it. If it turns out to be the second, it wakes the other thread.
locked
in class LockTest.LockUser
protected void released()
This is used to wake the main testing thread, which is waiting for both threads to release the lock.
released
in class LockTest.LockUser