mirror of
https://github.com/SourceFellows/gobuch.git
synced 2025-07-19 22:52:52 +02:00
initial import
This commit is contained in:
40
concurrency/java-threads-beispiel/Main.java
Normal file
40
concurrency/java-threads-beispiel/Main.java
Normal file
@ -0,0 +1,40 @@
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class Main {
|
||||
|
||||
static int count = 0;
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
while (true) {
|
||||
count++;
|
||||
try {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
while (true) {
|
||||
try {
|
||||
Thread.sleep(120000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("Thread Hello " + count);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
System.out.println("create native thread "+ count);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user