-
Notifications
You must be signed in to change notification settings - Fork 136
async and sync execution
async() and sync() can used to determine if subsequent tasks should be executed on the same thread as the completing task, or if they should be resubmitted to an Executor Service where they may be executed on a different thread. If async() is used the next tasks will be resubmitted for execution, if sync() is used the next tasks will be executed on the same thread as the completing task.
On a quad-core Mac Book Pro it is possible to do around ~335 million map operations per second in sync mode versus ~33 million in async mode. Use async to distribute work across threads (or for blocking operations) and sync to continue working efficiently on the completing thread. Benchmark for SimpleReact.
A mix of async and sync execution. There is a performance overhead of submitting tasks to an ExecutorService - for non-blocking fast running code this should be avoided where possible.
Typical aysnc execution where each completed task, triggers another task which submitted to an ExecutorService for execution.
oops - my bad