Made thread_sleep use a lock instead of disabling interrupts