Added semaphores and locks. Restructured thread sleeping.
Merge pull request #8 from kmmoore/mutex

Added semaphores and locks. Restructured thread sleeping.