Class Monitor
java.lang.Object
nl.tudelft.simulation.language.concurrent.Monitor
Monitor class. In the Java programming language there is a lock associated with every object. The language does not provide a
way to perform separate lock and unlock operations; instead, they are implicitly performed by high-level constructs that
always arrange to pair such operations correctly. This Monitor class, however, provides separate monitorenter and monitorexit
instructions that implement the lock and unlock operations. The class is final for now, as it is not the idea that the class
should be extended. It has only static methods.
Copyright (c) 2002-2024 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://simulation.tudelft.nl. The DSOL project is distributed under a three-clause BSD-style license, which can be found at https://https://simulation.tudelft.nl/dsol/docs/latest/license.html.
- Author:
- Peter H.M. Jacobs, Alexander Verbraeck
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
locks an object for the current thread.static void
locks an object for the given requestor.static void
unlocks an object locked by the current Thread.static void
unlocks an object locked by owner.
-
Method Details
-
lock
locks an object for the current thread.- Parameters:
object
- Object; the object to lock
-
lock
locks an object for the given requestor.- Parameters:
object
- Object; the object to lock.requestor
- Thread; the requesting thread.
-
unlock
unlocks an object locked by the current Thread.- Parameters:
object
- Object; the object to unlock
-
unlock
unlocks an object locked by owner.- Parameters:
object
- Object; the object to unlock.owner
- Thread; the owning thread.
-