'Multithreaded server creates multiple threads by fails to read

I have been making a multithreaded server, I cant share much but I will tell in clear theory how it is working. I have a server that goes in a while(true) loop and it waits for a connection. Everything works, it makes the multithreads. and the server does work when I read one at a time. However when I decide to run 10 threads, it returns and says it fails to read the message (in the cmd window).

Why is this or why could this be? I am also reading in the message by:

int characterNumer;
characterNumber = streamReader.read();
while(CharacterNumber > 0)
{
message += (char)CharacterNumber;
characterNumber = streamreader.read();
}

the second line is in a try catch statement twice so it does read. but for the server it fails. why is this? What would you recommend or advise? It does work perfectly when it is not multithreading.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source