Class AsyncExecutor

java.lang.Object
org.oscim.utils.async.AsyncExecutor

public class AsyncExecutor extends Object
Allows asnynchronous execution of AsyncTask instances on a separate thread. Needs to be disposed via a call to dispose() when no longer used, in which case the executor waits for running tasks to finish. Scheduled but not yet running tasks will not be executed.
  • Constructor Details

    • AsyncExecutor

      public AsyncExecutor(int maxConcurrent, TaskQueue mainloop)
      Creates a new AsynchExecutor that allows maxConcurrent Runnable instances to run in parallel.
      Parameters:
      maxConcurrent - number of threads.
  • Method Details

    • post

      public boolean post(Runnable task)
      Submits a Runnable to be executed asynchronously. If maxConcurrent runnables are already running, the runnable will be queued.
      Parameters:
      task - the task to execute asynchronously
    • dispose

      public void dispose()
      Waits for running AsyncTask instances to finish, then destroys any resources like threads. Can not be used after this method is called.