I want to count the time, how long all my task will work. But my variable timeElapsed is always 1
. Why?
Here is my code:
public class Main {
public static void main(String[] args) {
long start = System.currentTimeMillis();
for(String arg : args){
new Thread(() -> {
/* ... */
}).start();
}
long finish = System.currentTimeMillis();
long timeElapsed = finish - start; //always is 1
System.out.println("Elapsed time: " + timeElapsed);
}
}