Behavior of Jetty threads.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Behavior of Jetty threads.

daniel.mfreitas
After starting Jetty in embedded mode, I open the user browser using the new Java 6 Desktop class. I do all of this in the application main() method.

I noticed that while I am inside the main method (I added a break point after the browser is opened), the Jetty server does not answer the browser request. The page keeps loading as if waiting for the server response. As soon as the main() method finishes, I get the homepage in the browser.

I'm really intrigued why we have this behavior. Is it related to the way threads work in java? I'm concerned because after I start the server and open the browser, I start a new server socket on another port to listen for a command to stop the Jetty server.

Jetty will not answer my browser request until in my shutdown server socket thread I call serverSocket.accept();. Did I make myself clear?

Thanks in advance.