public class QueueTest extends NamingTest
This test starts five threads. The first two attempt to lock the root directory for shared access. The third attempts to lock it for exclusive access. The last two also attempt to take it for shared access. It then ensures that the following are true:
Note that each thread is started and allowed to try to take the lock before
the next thread, but no thread releases the lock until all threads have been
started. This allows all the threads to queue in the lock
method before the rest of the test precedes.
Threads should be served from the queue in the order they arrived. Shared access threads arriving after an exclusive access thread is queued should not be able to take the lock ahead of the shared access user.
Modifier and Type | Class and Description |
---|---|
private class |
QueueTest.QueuedLockUser
Queueing thread.
|
Modifier and Type | Field and Description |
---|---|
private boolean |
all_threads_started
Indicates that all threads have been started and have most likely queued
at the lock.
|
private static int |
DELAY
Delay between thread starts, in milliseconds.
|
private int |
lock_count
Number of threads that have succesfully locked the root directory.
|
static java.lang.String |
notice
Test notice.
|
static java.lang.Class[] |
prerequisites
Prerequisites.
|
private boolean |
rendezvous_first
Used to determine whether the current shared access user is the first at
the rendezvous, and therefore should wait, or is the second, and
therefore should wake the other thread.
|
private Path |
root
Path to the root directory.
|
private int |
thread_exits
Number of threads that have released the lock on the root directory.
|
private boolean |
wake_all
Indicates that the test is complete and any sleeping threads should be
awakened.
|
registration_stub, service_stub
Constructor and Description |
---|
QueueTest() |
Modifier and Type | Method and Description |
---|---|
protected void |
clean()
Wakes all threads.
|
protected void |
perform()
Performs the test.
|
private void |
startThread(boolean exclusive,
int expect_lock_count)
Starts a thread and gives it time to enter the root directory lock's
queue.
|
initialize
cleanupFailure, cleanupSuccess, failure, success, task, task
public static final java.lang.String notice
public static final java.lang.Class[] prerequisites
private final Path root
private boolean all_threads_started
private int lock_count
private boolean rendezvous_first
private int thread_exits
private static final int DELAY
lock
and
enter the lock's queue before the next thread started does so.private boolean wake_all
private void startThread(boolean exclusive, int expect_lock_count)
exclusive
- Whether or not the thread is to request exclusive
access to the root directory.expect_lock_count
- Number of threads the new thread expects to
have taken the lock by the time it does so.protected void clean()
clean
in class NamingTest