case WAITING: if (waitForMonitor == null) { throw new Error( "Waiting thread must have a waitForMonitor"); } if (!queueEntry.isInUse()) { throw new Error( "Waiting thread must have an inuse queueEntry"); }
case WAITING_ENTER: case WAITING_NOTIFY: case WAITING_NOTIFY_TIMEOUT: if (waitForMonitor == null) { throw new Error("Waiting thread must have a waitForMonitor"); } if (!queueEntry.isInUse()) { throw new Error("Waiting thread must have an inuse queueEntry"); }
    final void verifyState() throws UninterruptiblePragma {        switch (threadState) {        case CREATED:            if (queueEntry.isInUse()) { throw new Error(                    "Created thread cannot have an inuse queueEntry"); }            if (sleepQueueEntry.isInUse()) { throw new Error(                    "Created thread cannot have an inuse sleepQueueEntry"); }            break;        case ASLEEP:            if (queueEntry.isInUse()) { throw new Error(                    "Sleeping thread cannot have an inuse queueEntry"); }            if (!sleepQueueEntry.isInUse()) { throw new Error(                    "Sleeping thread must have an inuse sleepQueueEntry"); }            break;        case DESTROYED:            if (queueEntry.isInUse()) { throw new Error(                    "Destroyed thread cannot have an inuse queueEntry"); }            if (sleepQueueEntry.isInUse()) { throw new Error(                    "Destroyed thread cannot have an inuse sleepQueueEntry"); }            break;        case RUNNING:            if (!queueEntry.isInUse()) {                if (VmProcessor.current().getCurrentThread() != this) { throw new Error(                        "Running thread must be inuse on ready queue or current thread"); }            }            if (sleepQueueEntry.isInUse()) { throw new Error(                    "Running thread cannot have an inuse sleepQueueEntry"); }            break;        case STOPPED:            if (queueEntry.isInUse()) { throw new Error(                    "Stopped thread cannot have an inuse queueEntry"); }            if (sleepQueueEntry.isInUse()) { throw new Error(                    "Stopped thread cannot have an inuse sleepQueueEntry"); }            break;        case SUSPENDED:            if (queueEntry.isInUse()) { throw new Error(                    "Suspended thread cannot have an inuse queueEntry"); }            if (sleepQueueEntry.isInUse()) { throw new Error(                    "Suspended thread cannot have an inuse sleepQueueEntry"); }            break;        case WAITING:            if (waitForMonitor == null) { throw new Error(                    "Waiting thread must have a waitForMonitor"); }            if (!queueEntry.isInUse()) { throw new Error(                    "Waiting thread must have an inuse queueEntry"); }            break;        case YIELDING:            if (!queueEntry.isInUse()) { throw new Error(                    "Yielding thread must have an inuse queueEntry"); }            if (sleepQueueEntry.isInUse()) { throw new Error(                    "Yielding thread cannot have an inuse sleepQueueEntry"); }            break;        default:            throw new Error("Unknown thread state " + threadState);        }        // Now detect deadlocks        detectDeadlock();    }