Callbacks done by the task (to executor and/or listener), may be concurrent, for instance when the related future is cancelled. That lightweight lock, which internally uses just an atomic boolean, is used to ensure that these callbacks are done in proper order, and that there is no more callbacks done after the taskDone(...).