Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

increase Thread start performance in java

Is there a way to increase the performance of Thread.start method. as i know Thread.start will call the run method of the tread in a separate thread but i have found that it need time more than simple method call in the calling context.

like image 664
Mohammed Falha Avatar asked Jun 17 '13 16:06

Mohammed Falha


2 Answers

Starting threads definitely involves overhead. You may want to consider thread pooling.

http://docs.oracle.com/javase/tutorial/essential/concurrency/pools.html

like image 71
pamphlet Avatar answered Oct 29 '22 18:10

pamphlet


Thread.start is native. It does a lot more than calling run - it uses Operating System calls to create a thread stack and lots of other things. Consider using a Thread Pool.

like image 24
selig Avatar answered Oct 29 '22 17:10

selig