On Tuesday 14 September 2004 10:44, [EMAIL PROTECTED] wrote: > Oded Arbel wrote: > >On Tuesday 14 September 2004 09:35, [EMAIL PROTECTED] wrote: > >>Now you say that the benefit of using select is to cut-down the > >>number of threads/processes - > >>what do you expect to gain from this? Reduce memory use? > > > >Reduced overhead. The overhead of context switching between multiple > >threads, especially in Java, is quite large. multiply that by > > several thousands connections and you can grind any machine to a > > halt. > > > >I have programmed an HTTP client in Java - it replaced a system that > >used a single thread for each HTTP call (using Java's HTTP > > connector, > > What do you mean? Did the system you replaced use thread pools or > created a thread for > each call?
Initially it created a thread for each call. that sucked nuts so it was modified to use a thread pool which was slightly better but not by much. > >but I doubt other implementation would prove much better) with an > >implementation built from scratch to use simple non-blocking > >SocketChannels (not selectable channels. I might have got a few more > > How did you handle multiple concurrent connections? You say you > didn't use select() and > that the operations are non-blocking (I also see the JavaDocs of this > class right now), and you > imply that you didn't use multiple threads - so what did you do? Keep > a state for each socket > about what it has to do next? Yes - there's a single state machine object for each connection. It actually handles the socket infrastructure using the non-Blocking SocketChannel API directly and there's a single thread that iterates through the state machines and let each run in turn. even with several hundreds of connections it still mostly just waiting for IO, so why have multiple threads waiting when you can have one ? -- Oded ::.. The brain is a wonderful organ; it starts working the moment you get up in the morning, and does not stop until you get to school. ================================================================= To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]