Thread.holdsLock

Tags:

holdsLock

public static boolean holdsLock(Object obj)Returns true if and only if the current thread holds the monitor lock on the specified object.

This method is designed to allow a program to assert that the current thread already holds a specified lock:


assert Thread.holdsLock(obj);

Parameters:
obj – the object on which to test lock ownership

Returns:
true if the current thread holds the monitor lock on the specified object.

Throws:
NullPointerException – if obj is null

Since:
1.4

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *