Add synchronization

Synchronization is applied somewhat profusely in both classes.
This is because the task scheduler is single-threaded, and normally
does not schedule multiple tasks concurrently. Synchronization is
still needed, however, when executors are added or removed, but
these are relatively rare events so it is OK to synchronize this way.
Minor wording change