The below gist is a minimal piece of java code that helps in proving this
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 ThreadCreationTimeIncreasesWithNumberOfThreads { | |
public static void main(String[] args) { | |
long threadCreationTime = 0, noOfThreadsCreated=1; | |
while (true) { | |
long time = System.currentTimeMillis(); | |
new Thread() { | |
public void run() {} | |
}.start(); | |
time = System.currentTimeMillis() - time; | |
if (time > threadCreationTime) { | |
System.out.println(noOfThreadsCreated + " numbered thread created in " + time + "ms."); | |
threadCreationTime = time; | |
} | |
noOfThreadsCreated++; | |
} | |
} | |
} |
You'll see a output similar to:
1 numbered thread created in 2ms
100 numbered thread created in 6ms
173 numbered thread created in 15ms
1144 numbered thread created in 19ms
100 numbered thread created in 6ms
173 numbered thread created in 15ms
1144 numbered thread created in 19ms
1144
numbered thread created in 19ms.
3161
numbered thread created in 22ms.
6486
numbered thread created in 32ms.
7079
numbered thread created in 36ms.
No comments:
Post a Comment