Method and apparatus for high-concurrency client locking with java in a data processing system
First Claim
1. A method for multithreaded execution in a data processing system for managing access to objects in a container by way of synchronized blocks, the method comprising:
- using an identifier object to retrieve a mutex object from a value set, wherein the identifier object has a value that distinguishes the mutex object from other objects in the value set and that also distinguishes a desired object from other objects in the container;
in response to retrieving the mutex object from the value set, entering a synchronized block that locks the mutex object;
while in the synchronized block that locks the mutex object, accessing the container to determine whether the desired object is present within the container;
while in the synchronized block that locks the mutex object, in response to a determination that the desired object is not within the container, producing the desired object from an alternative source for insertion into the container;
while in the synchronized block that locks the mutex object, accessing the desired object from the container; and
exiting the synchronized block that locks the mutex object, whereby mutual exclusion with respect to accessing the desired object is maintained regardless or whether the desired object is present with the container.
3 Assignments
0 Petitions
Accused Products
Abstract
The present invention provides a method and apparatus in a data processing system for managing access to objects (called an element) in a collection of objects (called a container) in a high-concurrency environment. A request is received from a requester for an element'"'"'s mutex given an identifier for the element. This mutex can be used as a mutex in a synchronized block to lock the object during that synchronized block. To compute the mutex for an element, the first instance seen by the container of the element'"'"'s identifier is used. To do this, a determination is made as to whether there is already an instance of the identifier with the same value in a value set. If so, that value is returned to the requester for use as a mutex. If not, the current identifier instance is saved in the value set and returned. This allows the object to be locked prior to the existence of the object.
16 Citations
18 Claims
-
1. A method for multithreaded execution in a data processing system for managing access to objects in a container by way of synchronized blocks, the method comprising:
-
using an identifier object to retrieve a mutex object from a value set, wherein the identifier object has a value that distinguishes the mutex object from other objects in the value set and that also distinguishes a desired object from other objects in the container;
in response to retrieving the mutex object from the value set, entering a synchronized block that locks the mutex object;
while in the synchronized block that locks the mutex object, accessing the container to determine whether the desired object is present within the container;
while in the synchronized block that locks the mutex object, in response to a determination that the desired object is not within the container, producing the desired object from an alternative source for insertion into the container;
while in the synchronized block that locks the mutex object, accessing the desired object from the container; and
exiting the synchronized block that locks the mutex object, whereby mutual exclusion with respect to accessing the desired object is maintained regardless or whether the desired object is present with the container. - View Dependent Claims (2, 3, 4, 5, 6)
determining whether any mutex object that is associated with the value of the identifier object exists within the value set; and
in response to a determination that no mutex object that is associated with the value of the identifier object exists within the value set, creating the mutex object for insertion into the value set.
-
-
3. The method of claim 1, wherein the synchronized block that locks the mutex object is a first synchronized block and accessing the desired object from the container includes:
-
while in the first synchronized block, entering a second synchronized block that locks the container;
while in the second synchronized block, retrieving the desired object from the container; and
exiting the second synchronized block.
-
-
4. The method of claim 1, wherein the identifier object is a string.
-
5. The method of claim 1, wherein the container is a cache.
-
6. The method of claim 1, wherein the method is executed in a Java virtual machine.
-
7. A multithreaded computer program product for managing access to objects in a container by way of synchronized blocks, the computer program product being in a computer-readable medium and comprising instructions that, when executed by a computer, cause the computer to perform actions that include:
-
using an identifier object to retrieve a mutex object from a value set, wherein the identifier object has a value that distinguishes the mutex object from other objects in the value set and that also distinguishes a desired object from other objects in the container;
in response to retrieving the mutex object from the value set, entering a synchronized block that locks the mutex object;
while in the synchronized block that locks the mutex object, accessing the container to determine whether the desired object is present within the container;
while in the synchronized block that locks the mutex object, in response to a determination that the desired object is not within the container, producing the desired object from an alternative source for insertion into the container;
while in the synchronized block that locks the mutex object, accessing the desired object from the container; and
exiting the synchronized block that locks the mutex object, whereby mutual exclusion with respect to accessing the desired object is maintained regardless of whether the desired object is present within the container. - View Dependent Claims (8, 9, 10, 11, 12)
determining whether any mutex object that is associated with the value of the identifier object exists within the value set; and
in response to a determination that no mutex object that is associated with the value of the identifier object exists within the value set, creating the mutex object for insertion into the container.
-
-
9. The computer program product of claim 7, wherein the synchronized block that locks the mutex object is a first synchronized block and accessing the desired object from the container includes:
-
while in the first synchronized block, entering a second synchronized block that locks the container;
while in the second synchronized block, retrieving the desired object from the container; and
exiting the second synchronized block.
-
-
10. The computer program product of claim 7, wherein the identifier object is a string.
-
11. The computer program product of claim 7, wherein the container is a cache.
-
12. The computer program product of claim 7, wherein the instructions are executed in a Java virtual machine.
-
13. A data processing system for managing access to objects in a container by way of synchronized blocks comprising:
-
means for using an identifier object to retrieve a mutex object from a value set, wherein the identifier object has a value that distinguishes the mutex object from other objects in the value set and that also distinguishes a desired object from other objects in the container;
means, responsive to retrieving the mutex object from the value set, for entering a synchronized block that locks the mutex object;
means, operative while in the synchronized block that locks the mutex object, for accessing the containew to determine whether the desired object is present within the container;
means, operative while in the synchronized block that locks the mutex object and responsive to a determination that the desired object is not within the container, for producing the desired object from an alternative source for insertion into the container;
means, operative while in the synchronized block that locks the mutex object, for accessing the desired object form the container; and
means for exiting the synchronized block that locks the mutex object, whereby mutual exclusion with respect to accessing the desired object is maintained regardless of whether the desired object is present with the container. - View Dependent Claims (14, 15, 16, 17, 18)
means for determining whether any mutex object that is associated with the value of the identifier object exists within the value set; and
means, responsive to a determination that no mutex object that is associated with the value of the identifier object exists within the value set, for creating the mutex object for insertion into the value set.
-
-
15. The data processing system of claim 13, wherein the synchronized block that locks the mutex object is a first synchronized block and the means for accessing the desired object from the container includes:
-
means, operative while in the first synchronized block, for entering a second synchronized block that locks the container;
means, operative while in the second synchronized block, for retrieving the desired object from the container; and
means for exiting the second synchronized block.
-
-
16. The data processing system of claim 13, wherein the identifier object is a string.
-
17. The data processing system of claim 13, wherein the container is a cache.
-
18. The data processing system of claim 13, wherein the data processing system is executed in a Java virtual machine.
Specification