[JENKINS-21932] - Fixed the synchronization issue for cancel() operation...

...s

The issue may cause the JENKINS-21932, which seems to be caused by unhandled locks()
I'm not sure...

Signed-off-by: Oleg Nenashev <o.v.nenashev@gmail.com>