blob: d091e0aa19582f2d67214d3a11e1fca640dcb60b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
public class Main {
public static volatile boolean running = true;
public static int cnt = 0;
public static void main(String[] args) throws InterruptedException {
System.out.println("start");
Thread t = new Thread( () -> { System.out.println("Ich bin ein Thread"); while (running) { cnt++; }; } );
t.start();
Thread.sleep(1000);
running = false;
t.join();
System.out.println("ende");
System.out.println("ausgefuhrt: " + cnt);
System.err.println(cnt);
}
}
|