Skip to content

Instantly share code, notes, and snippets.

@langmi
Created September 19, 2011 07:46
Show Gist options
  • Save langmi/1226119 to your computer and use it in GitHub Desktop.
Save langmi/1226119 to your computer and use it in GitHub Desktop.
AsyncTaskExecutorFactory example
public class AsyncTaskExecutorFactory {
...
public static SimpleAsyncTaskExecutor createInstance() {
SimpleAsyncTaskExecutor instance = new SimpleAsyncTaskExecutor();
// set concurrencyLimit according to available processors
// real simple 1:1 relation
Runtime runtime = Runtime.getRuntime();
int nrCpu = runtime.availableProcessors();
instance.setConcurrencyLimit(nrCpu);
return instance;
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment