Adding Thread.sleep to facilitate switching between the threads