getWaitQueueLength throws IllegalArgumentException: Not owner

I’m doing a concurrency problem homework. I have many threads doing specific things and a method which decides when these threads can access a resource.

So my class looks something like this:

public class Boss extends ReentrantLock implements Runnable {

    Lock access = new ReentrantLock();
    Condition canTakeOff = access.newCondition();
    Condition canLand = access.newCondition();

    public void accessToLanding(){
                if(getWaitQueueLength(canTakeOff) > 0){
                } else if {
                 /* some other cases */
            } catch (InterruptedException e){
            } finally {

    public void run(){

    /* Methods which are called by objects of a different class, 
    they are awaiting for the signal from accessToLanding.*/

I’m getting the error:

Exception in thread "Thread-0" java.lang.IllegalArgumentException: Not owner
at java.util.concurrent.locks.AbstractQueuedSynchronizer.getWaitQueueLength(
at java.util.concurrent.locks.ReentrantLock.getWaitQueueLength(

I’ve checked the documentation and it says that getWaitQueueLength throws IllegalArgumentException when “the given condition is not associated with this lock” but from what I understand, it is associated in my code. Can someone help me?


When you invoke


you are calling


where this is your instance of Boss. Despite canTakeOff has been declared has a member, it doesn’t belong to Boss, it is a Condition obtained from access

I think that you must change the aforementioned line a bit and use


More info: Javadoc getWaitQueueLength throws IllegalArgumentException

Leave a Reply

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