com.dg.libs.rest.services.ThreadCountObserver Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of android-rest Show documentation
Show all versions of android-rest Show documentation
This is a library for android for Making RestFul Requests
/**
*
*/
package com.dg.libs.rest.services;
import java.util.LinkedList;
import com.araneaapps.android.libs.logger.ALog;
/** @author darko.grozdanovski */
public abstract class ThreadCountObserver {
public static final String TAG = ThreadCountObserver.class.getSimpleName();
public abstract void onThreadsFinished();
public abstract void newRunnableRegistered();
LinkedList observerList = new LinkedList();
public void registerRunnable(final Runnable r) {
synchronized (observerList) {
observerList.add(r);
}
newRunnableRegistered();
ALog.d(TAG, "observer list size on register: " + observerList.size());
}
public void unregisterRunnable(final Runnable r) {
synchronized (observerList) {
observerList.remove(r);
}
ALog.d(TAG, "observer list size on unregister: " + observerList.size());
if (observerList.size() == 0) {
ALog.d(TAG, "observer calling finish method");
onThreadsFinished();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy