How to use TimeUnit in java
Try this as your code have many syntax errors
as well as you are not handling Exception
during the call of TimeUnit.SECONDS.sleep(6);
, either use throws or surround this with try catch.
import java.util.concurrent.TimeUnit ;
public class Anything {
public static void main( String[] args ) throws InterruptedException {
System.out.println("hi");
TimeUnit.SECONDS.sleep(6);
System.out.println("hi");
}
}
Ibraheem Alyan
I am a self-educated Full-Stack Web Developer (prefer back-end) and a certified Linux administrator ( CompTIA Linux + ) ,I build web apps with Python server side based on famous frameworks like Django and Flask. I implement RESTful and SOAP APIs, and I can take care of every single layer in a web application: implementing server side code, administrating SQL and NoSQL databases, deploying, monitoring and maintaining Linux servers, building basic web frontends and a lot more.
Updated on December 11, 2020Comments
-
Ibraheem Alyan over 3 years
I am trying to use TimeUnit in java but it just send me errors That’s how I wrote it
import java.util.concurrent.TimeUnit ; public class Anything { public static void main( String[] args ) { System.out.println("hi"); TimeUnit.SECONDS.sleep(6); System.out.println("hi"); } }