mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-30 10:26:58 +01:00
add pause() and resume()
This commit is contained in:
parent
1e30582c3b
commit
7c45e3c5b3
1 changed files with 38 additions and 0 deletions
|
@ -166,6 +166,42 @@ public class JNIThread extends Thread {
|
||||||
m_queue = new LinkedBlockingQueue<QueueElem>();
|
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 )
|
public void waitToStop( boolean save )
|
||||||
{
|
{
|
||||||
synchronized ( this ) {
|
synchronized ( this ) {
|
||||||
|
@ -309,6 +345,8 @@ public class JNIThread extends Thread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkPaused();
|
||||||
|
|
||||||
QueueElem elem;
|
QueueElem elem;
|
||||||
Object[] args;
|
Object[] args;
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue