我的程序建立很多线程通向一个服务器,这些线程分别从服务器下载。当线程达到5000时 I'm sure increasing memory would solve the OutOfMemory error, but I don't think having 5000 threads running at the same time is a good idea to begin with... (is that even possible without hogging up the whole thing?)
【在 f********h 的大作中提到】 : java -X
g*g
5 楼
Might be a research project only for theoretical interest. Or a load test?
【在 m******t 的大作中提到】 : : 我的程序建立很多线程通向一个服务器,这些线程分别从服务器下载。当线程达到5000时 : I'm sure increasing memory would solve the OutOfMemory error, but I don't : think having 5000 threads running at the same time is a good idea to begin : with... (is that even possible without hogging up the whole thing?)
M*r
6 楼
我的程序建立很多线程通向一个服务器,这些线程分别从服务器下载。当线程达到5000时 Unless you run a large-scale application in a mainframe with 5000 CPUs, I dont see any reason to spawn 5000 threads. The overhead of thread context switching alone will make your design look silly. If you deal with I/O related problems, I suggest you take a look at NIO introduced in JDK1.4. Specifically using selector is far better a choice to deal with I/O multiplexing than forking thread. Check out the following article: http://www.onjava.com/pub/a/on