Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mdtareque/8185501 to your computer and use it in GitHub Desktop.
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
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