mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 02:39:23 +02:00
synchronization thread
This commit is contained in:
parent
c0ace6ad75
commit
7d840b81af
1 changed files with 18 additions and 0 deletions
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue