Last active
January 1, 2016 18:39
-
-
Save mdtareque/8185501 to your computer and use it in GitHub Desktop.
Java Thread creation time increases with the number of Threads created. Little more description can be found at http://mtktechiecode.blogspot.in/2014/01/java-analyzing-thread-creation-time.html
This file contains 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++; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment