Created
December 11, 2023 20:47
-
-
Save nihat-js/e43822134eb9b4b3b7144d47c1ff4979 to your computer and use it in GitHub Desktop.
JavaThreadTest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ZombieThreadTester { | |
public static void main(String[] args) { | |
Thread[] threads = new Thread[100]; | |
for (int i = 0; i < 100; i++) { | |
threads[i] = new Thread(new MyRunnable(i)); | |
} | |
for (int i = 0; i < 100; i++) { | |
threads[i].start(); | |
} | |
} | |
} | |
class MyRunnable implements Runnable { | |
private int index; | |
MyRunnable(int index) { | |
this.index = index; | |
} | |
@Override | |
public void run() { | |
System.out.println("running" + index); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment