Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.56 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.     private static int zm = 0;
  6.  
  7.     private static Runnable r = () -> {
  8.         for (int i = 0; i < 10_000_000; ++i) {
  9.             zm++;
  10.         }
  11.     };
  12.  
  13.     public static void main(String[] args) throws InterruptedException {
  14.         Thread t = new Thread(r);
  15.         long start = System.nanoTime();
  16.  
  17.         t.start();
  18.         t.join();
  19.         long stop = System.nanoTime();
  20.        
  21.         System.out.println("time  = " + ((stop - start) / 1e9));
  22.         System.out.println("zm = " + zm);
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement