Greetings
I am running my webapp on Tomcat6 on Java6 on Ubuntu8.04. The main servlet of this app opens a ServerSocket, with the following simple code:
ServerSocket serverSocket = new ServerSocket(6767);
Socket xmlSocket = serverSocket.accept();
Of course this runs in a separate thread and with the necessary try-catch blocks.
When I start Tomcat, it immediately goes to 100% CPU load and stays there until a client connects on port 6767. For as long as the client is connected, load goes down to 0%. As soon as the client disconnects, load goes back up to 100%.
Can anybody tell me what this is about?
Thanks!
SOLUTION:
Both the answers below were very helpful. The problem did NOT actually have to do with the ServerSocket, but with a sleepless while loop in a completely different thread of the app, but also dependent on whether a client was connected or not.
I was able to identify the active threads with the JDK command "jstack" and then it was an easy thing to find the one with the runaway loop.
Thanks for the help! :)