In Java it works by accepting an object which implements runnable :
Thread myThread = new Thread(new myRunnable())
where myRunnable
myRunnable
Please try this code:
Thread().run { Thread.sleep(3000); }