Guest User

Untitled

a guest
Jul 18th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. public class App {
  2.  
  3. public static void main(String[] args) throws InterruptedException {
  4. System.out.println("Starting ...");
  5.  
  6. Thread t1 = new Thread(new Runnable() {
  7. public void run() {
  8. Random random = new Random();
  9.  
  10. for (int i = 0; i < 1E7; i++) {
  11.  
  12. try {
  13. Thread.sleep(1);
  14. } catch (InterruptedException ex) {
  15. System.out.println("Interrupted Exception!");
  16. break;
  17. }
  18.  
  19. Math.sin(random.nextInt());
  20. }
  21. }
  22. });
  23.  
  24. t1.start();
  25.  
  26. Thread.sleep(500);
  27.  
  28. t1.interrupt();
  29.  
  30. t1.join();
  31.  
  32. System.out.println("Finished.");
  33. }
  34. }
Add Comment
Please, Sign In to add comment