Éjmélyböl wrote:
2004-06-14, h keltezéssel 18:02-kor Daniel Malmkvist ezt írta:Hi
Hi
I have a question about threads. I was wondering about what realy happens to a thread on the OS level when i set it to read from a socket when there is no data there. I use Native threads (not green threads).
Will the thread realy sleep, no contex switch will be done. The thread will sleep until a the OS get a interruption from the NIC.
or will thread contex switching still be done to see if there is data to be read.
I have an application that should handle alot (>10 000) connection at the same time but usally no traffic. Is the best way to make a thread pool or is the best way to have 1 thread per connection. If no contex switching will be done I don't see why not.
Best regard
/daniel
You shouldn't use blocking IO, if you really want so much concurrent connections. I've never ever seen a native threading JVM, which were able to manage thousands of threads (Due to limitations of linux kernels 2.4) So i advise you to use java.nio (non-blocking IO, with selectors)
BR Zsombor
---------------------------------------------------------------------- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Thanks for all the ansers.
I have done som test to see how many threads i could manage at the same time. with the 2.6.x kernel with NPTL enabled + sun JVM 1.4.2 I was able to have >10 000 threads at the same time. The limiting factor was the addressspace of my 32 bit plattform. But if I move to a 64 bit plattform that wouldn't be the case anylonger.
What I understand a thread pool will do lot pf unnessesary polling to no good. But in the 1-thread per connection case the only resorces that will be reserverd is a bit of memory (and on a 64 bit plattform that is not a problem). Or am I missing anything, is there any other resorces that will be allocated.
/daniel
---------------------------------------------------------------------- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]