You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
johnmcclean-aol edited this page Apr 8, 2015
·
1 revision
async() and sync() operators
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.