1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-05 02:39:23 +02:00

synchronization thread

This commit is contained in:
Nikolay Pultsin 2014-06-22 19:35:32 +01:00
parent c0ace6ad75
commit 7d840b81af

View file

@ -27,6 +27,7 @@ import org.geometerplus.android.fbreader.libraryService.BookCollectionShadow;
public class SynchroniserService extends Service implements Runnable { public class SynchroniserService extends Service implements Runnable {
private final BookCollectionShadow myCollection = new BookCollectionShadow(); private final BookCollectionShadow myCollection = new BookCollectionShadow();
private volatile Thread mySynchronizationThread;
@Override @Override
public IBinder onBind(Intent intent) { public IBinder onBind(Intent intent) {
@ -37,6 +38,23 @@ public class SynchroniserService extends Service implements Runnable {
@Override @Override
public void run() { public void run() {
System.err.println("SYNCHRONIZER BINDED TO LIBRARY"); System.err.println("SYNCHRONIZER BINDED TO LIBRARY");
synchronized(this) {
if (mySynchronizationThread == null) {
mySynchronizationThread = new Thread() {
public void run() {
System.err.println("HELLO THREAD");
try {
mySynchronizationThread.sleep(5000);
} catch (InterruptedException e) {
}
System.err.println("BYE-BYE THREAD");
mySynchronizationThread = null;
}
};
mySynchronizationThread.setPriority(Thread.MIN_PRIORITY);
mySynchronizationThread.start();
}
}
} }
@Override @Override