mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-11 11:35:07 -05:00
36 lines
708 B
Java
36 lines
708 B
Java
package org.apg;
|
|
|
|
public class PausableThread extends Thread {
|
|
private boolean mPaused = false;
|
|
|
|
public PausableThread(Runnable runnable) {
|
|
super(runnable);
|
|
}
|
|
|
|
public void pause() {
|
|
synchronized (this) {
|
|
mPaused = true;
|
|
while (mPaused) {
|
|
try {
|
|
wait();
|
|
} catch (InterruptedException e) {
|
|
// ignore
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void unpause() {
|
|
synchronized (this) {
|
|
mPaused = false;
|
|
notify();
|
|
}
|
|
}
|
|
|
|
public boolean isPaused() {
|
|
synchronized (this) {
|
|
return mPaused;
|
|
}
|
|
}
|
|
}
|