fix: async task, handle RejectedExecutionException

This commit is contained in:
Hannes Janetzek 2014-01-17 15:13:04 +01:00
parent bfb86e0a57
commit f385725311
2 changed files with 10 additions and 3 deletions

View File

@ -52,8 +52,9 @@ public class AsyncExecutor implements Disposable {
*
* @param task the task to execute asynchronously
*/
public void post(Runnable task) {
public boolean post(Runnable task) {
Gdx.app.postRunnable(task);
return true;
}
/**

View File

@ -19,6 +19,7 @@ package org.oscim.utils.async;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
@ -78,8 +79,13 @@ public class AsyncExecutor {
*
* @param task the task to execute asynchronously
*/
public void post(Runnable task) {
executor.execute(task);
public boolean post(Runnable task) {
try {
executor.execute(task);
} catch (RejectedExecutionException e) {
return false;
}
return true;
}
/**