Package com.sun.javatest
Class ResourceTable
java.lang.Object
com.sun.javatest.ResourceTable
A table providing simple named locks for arbitrary resources.
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a resource table.ResourceTable
(int initialSize) Create a resource table of a specified size. -
Method Summary
-
Constructor Details
-
ResourceTable
public ResourceTable()Create a resource table. -
ResourceTable
public ResourceTable(int initialSize) Create a resource table of a specified size.- Parameters:
initialSize
- a hint as to the initial capacity to make the table
-
-
Method Details
-
acquire
Try to acquire a set of named locks. To avoid deadlocks, the locks are acquired in a canonical order (alphabetical by name.)- Parameters:
resourceNames
- a list of names identifying locks to be acquired.timeout
- a maximum time, in milliseconds to ait for the locks to become available.- Returns:
- true if and only if all the locks were successfully acquired
- Throws:
InterruptedException
- is the method was interrupted while waiting for the locks to become available.
-
release
Release a set of previously acquired locks. The named locks are only released if currently owned by the same thread that acquired them.- Parameters:
resourceNames
- the names of the locks to be released
-
table
Returns unmodifiable copy of the resource table. Table contains resource names mapped to threads that originally calledacquire
method. Please note that query operations on the returned map "read through" to the internal original map which could be changing over time.- Returns:
- unmodifiable resource table
-