Search code examples
myeclipse

which library I have to include in my eclipse to use Thread.sleep()


I want to use in my code : "Thread.sleep(10000);" in my esclipe

in netbeans it worked and I just included: "import java.io.; import java.net.;" so what should i do in myeclipse to use it

thank u


Solution

  • You just need to make sure you handle any exceptions that could arise. Adding a try/catch statement will do the trick:

        try {
           Thread.sleep(500);
        } catch(InterruptedException e) {
           Thread.currentThread().interrupt(); 
        }
    

    Hope this helps!