Guest User

Untitled

a guest
Jul 15th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. public class App {
  2.  
  3. public static void main(String[] args) {
  4. ExecutorService executor = Executors.newCachedThreadPool();
  5.  
  6. executor.submit(new Runnable() {
  7.  
  8. public void run() {
  9. Random random = new Random();
  10. int duration = random.nextInt(4000);
  11.  
  12. System.out.println("Starting ... ");
  13.  
  14. try {
  15. Thread.sleep(duration);
  16. } catch (InterruptedException ex) {
  17. Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);
  18. }
  19.  
  20. System.out.println("Finished ... ");
  21. }
  22. });
  23. executor.shutdown();
  24. }
  25. }
Add Comment
Please, Sign In to add comment