fixed sleep for signal safely when dequeue. and, fixed some example codes and tests.