Tomcat6 on Linux uses a 100% processor when ServerSocket is idle

Hi

I am running my webapp on Tomcat6 on Java6 on Ubuntu8.04. The main servlet of this application opens a ServerSocket with the following simple code:

ServerSocket serverSocket = new ServerSocket(6767);

Socket xmlSocket = serverSocket.accept();        

Of course, this works in a separate thread and with the necessary try-catch blocks.

When I start Tomcat, it immediately switches to 100% processor utilization and remains there until the client connects to port 6767. While the client is connected, the load decreases to 0%. As soon as the client disconnects, the download returns to 100%.

Can someone tell me what that means?

Thank!

DECISION:

. ServerSocket, while , , .

JDK "jstack", , .

!:)

+3
2

, 100%.

"while loop" sleep() .
.

:

try
{
  while (m_flagRunUserThreadManager)
  {
    try
    {
      m_listenSocket.setSoTimeout(10000);
      Socket clientSocket = m_listenSocket.accept();
      //create a thread for client
      MyClientHandler clientHandler = new ClientHandler(clientSocket);
      clientHandler.setPriority(Thread.MIN_PRIORITY);
      clientHandler.start(); 

    }
    catch(SocketTimeoutException excp)
    {
      String strError = "No requests for 10 Sec.";
      //display this message    
    }
  }
}
catch(IOException excp)
{
    // display the exception
}

, while loop , .
-, / . , , alreay .

+1

, , , - , 100%, Ctrl-Break ( SendSignal ). , , , , .

+2

Source: https://habr.com/ru/post/1734768/


All Articles