Fixing a rare race condition in multi threading library causing segmentation fault on multiple work dequeuing.