public void run() {
passed[0] = true;
}
});
PlatformGIS.wait(200, WAIT_LENGTH, new WaitCondition(){
public boolean isTrue() {
return passed[0] = true;
}
}, null);
assertTrue(passed[0]);
states.remove(State.THREAD_HAS_LOCK);
lock.unlock();
while( !states.contains(State.DISPLAY_HAS_LOCK) )
Thread.sleep(200);
lockLock.lock();
states.add(State.THREAD_WAITING_FOR_LOCK);
lock.lock();
states.add(State.THREAD_HAS_LOCK);
lockLock.unlock();
PlatformGIS.wait(200, WAIT_LENGTH, new WaitCondition(){
public boolean isTrue() {
return passed[0];
}
}, null);
lock.unlock();
states.remove(State.THREAD_HAS_LOCK);
states.add(State.THREAD_RELEASED_LOCK);
} catch (Throwable e) {
exception[0] = e;
displayThread.interrupt();
}
}
};
Thread t = new Thread(other, "Lock Test Thread"); //$NON-NLS-1$
t.start();
// wait til thread has lock
UDIGTestUtil.inDisplayThreadWait(WAIT_LENGTH, new WaitCondition(){
public boolean isTrue() {
return states.contains(State.THREAD_HAS_LOCK);
}
}, false);
lockLock.lock();
states.add(State.DISPLAY_WAITING_FOR_LOCK);
lock.lock();
states.remove(State.DISPLAY_WAITING_FOR_LOCK);
states.add(State.DISPLAY_HAS_LOCK);
lockLock.unlock();
// make sure thread has released lock.
if (exception[0] != null)
throw exception[0];
assertFalse(states.contains(State.THREAD_HAS_LOCK));
assertTrue(passed[0]);
passed[0] = false;
UDIGTestUtil.inDisplayThreadWait(WAIT_LENGTH, new WaitCondition(){
public boolean isTrue() {
return states.contains(State.THREAD_WAITING_FOR_LOCK);
}
}, false);
if (exception[0] != null)
throw exception[0];
states.remove(State.DISPLAY_HAS_LOCK);
lock.unlock();
UDIGTestUtil.inDisplayThreadWait(5000, new WaitCondition(){
public boolean isTrue() {
return states.contains(State.THREAD_HAS_LOCK);
}
}, false);
if (exception[0] != null)
throw exception[0];
passed[0] = true;
UDIGTestUtil.inDisplayThreadWait(5000, new WaitCondition(){
public boolean isTrue() {
return states.contains(State.THREAD_RELEASED_LOCK);
}