fix thread sleep usage to enable sleep with milliseconds