add pause() and resume()

This commit is contained in:
Eric House 2014-02-13 19:26:09 -08:00
parent 1e30582c3b
commit 7c45e3c5b3

View file

@ -166,6 +166,42 @@ public class JNIThread extends Thread {
m_queue = new LinkedBlockingQueue<QueueElem>();
}
public synchronized void pause()
{
// DbgUtils.logf( "JNIThread.pause()" );
Assert.assertNotNull( m_lock );
m_lock = null;
}
public void resume( GameLock newLock )
{
Assert.assertTrue( newLock.canWrite() );
Assert.assertNull( m_lock );
m_lock = newLock;
// DbgUtils.logf( "resume: calling notify()" );
synchronized( this ) {
this.notify();
}
}
private void checkPaused()
{
// DbgUtils.logf( "checkPaused()" );
for ( ; ; ) {
synchronized( this ) {
if ( null != m_lock ) {
break;
}
try {
wait();
} catch ( java.lang.InterruptedException ie ) {
DbgUtils.loge( ie );
}
}
}
// DbgUtils.logf( "checkPaused() DONE" );
}
public void waitToStop( boolean save )
{
synchronized ( this ) {
@ -309,6 +345,8 @@ public class JNIThread extends Thread {
}
}
checkPaused();
QueueElem elem;
Object[] args;
try {