摘要 |
A method and an apparatus for synchronizing Java resource access. The method includes configuring for a first access interface of a resource set, a first monitor, and configuring, for a second access interface of the resource set, a second monitor, configuring, for the first monitor, a first waiting queue, and the second monitor, a second waiting queue, in response to the first access interface receiving an access request for a resource from a thread, the first monitor querying whether the resource set has a resource satisfying the access request, in response to a positive querying result, the thread obtains the resource and notifies the second monitor to awake a thread in the second waiting queue, in response to a negative querying result, the first monitor puts the thread in the first waiting queue to queue up.
|