mirror of
https://github.com/Relintai/programming_tutorials.git
synced 2025-05-13 23:02:12 +02:00
41 lines
889 B
Java
41 lines
889 B
Java
|
|
|
|
class JavaThreadsWithExtend extends Thread {
|
|
|
|
|
|
public void run() {
|
|
try {
|
|
System.out.println(Thread.currentThread().getId());
|
|
} catch (Exception e) {
|
|
System.out.println("ex");
|
|
}
|
|
}
|
|
}
|
|
|
|
class JavaThreadhWithInterface implements Runnable {
|
|
public void run() {
|
|
try {
|
|
System.out.println(Thread.currentThread().getId());
|
|
} catch (Exception e) {
|
|
System.out.println("ex");
|
|
}
|
|
}
|
|
}
|
|
|
|
class JavaThreadingAlapok {
|
|
|
|
public static void main(String args[]) {
|
|
|
|
for (int i = 0; i < 8; ++i) {
|
|
JavaThreadsWithExtend obj = new JavaThreadsWithExtend();
|
|
obj.start();
|
|
}
|
|
|
|
for (int i = 0; i < 8; ++i) {
|
|
Thread obj = new Thread(new JavaThreadhWithInterface());
|
|
obj.start();
|
|
}
|
|
|
|
System.out.println("Teszt");
|
|
}
|
|
} |