Back to project page android-sync-nosql.
The source code is released under:
MIT License
If you think the Android project android-sync-nosql listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.znck.android.nosql.util; // w w w . ja v a 2 s. c om import android.util.Log; import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; public abstract class WaitForResult { private Lock lock = new ReentrantLock(); private boolean working = false; private Condition workingCondition = lock.newCondition(); abstract public void run(); public final void execute() { Log.d("SYNC", "Executing tasks"); lock.lock(); try { run(); while (working) { Log.d("SYNC", "Waiting for tasks"); workingCondition.awaitUninterruptibly(); } } finally { Log.d("SYNC", "Tasks finished"); unlock(); lock.unlock(); } } public final void lock() { working = true; } public final void unlock() { working = false; } }