Originally posted by Stan James:
Yup, show us where you're going in a little more detail. You can't have multiple threads reading from the same socket at the same time. But you could have a driver that reads a message and hands it off to a thread for handling. The driver could read at the speed of the network and not be slowed down by the server code that runs in response to each message.
The logic would be something like:
Hmmm, there must be a cleane way to say that without three reads. Lemme know if that's going the right direction.
If you get tons of messages faster than you can handle them you'll wind up with tons of threads which could be very bad. If the number of threads or the overhead of creating them becomes a problem, look into thread pools. The Jakarta Commons has a nice one.
Hi Stan,
Instead of reading the message and passing each message to a Thread,I want the Thread to read the message till it encounters a #.Have already sent the code.I would alsolike to know,if there would be a better preformance this way!!!
I tried using your code as well,but it gives me NullPointerException,when it tries to read the message the 2nd time...though it works well the first time.
Thanks!!