Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2005

Tip: Looking for answers? Try searching our database.

Tomcat, creating threads

Thread view: 
Ghost - 31 May 2005 19:16 GMT
I am trying to do some thread profiling on a website that consists
almost entirely of JSPs.  When I create a thread in my application, I
give it a relevant name.

The problem is, I am seeing other threads that are calling my classes.
Are these threads being created by Tomcat?

The "unknown" threads have names like: Thread-17, Thread-18, etc.
I'm not sure, but I think these threads are being created every time my
JSPs try to access a session.  Is there any way to tell where these
threads are coming from?  Or, if they are being created by tomcat, can
I tell tomcat to name them something different?

Thanks in advance.
Brooks Hagenow - 01 Jun 2005 08:16 GMT
> I am trying to do some thread profiling on a website that consists
> almost entirely of JSPs.  When I create a thread in my application, I
[quoted text clipped - 10 lines]
>
> Thanks in advance.

Yes, Tomcat creates its own threads as do all Java application servers.
 Each request is processed on its own thread and the same servlet/JSP
may be used by multiple threads at once.

You may prevent multiple threads from simultaneously accessing a servlet
by implementing SingleThreadModel but that does not prevent the
application server from creating multiple instances of the servlet.  If
you have an instance variable in your servlet (bad idea) that acts as a
counter, you may notice when outputting the value that the value starts
to appear random.  That would behavior would be caused by each servlet
instance having its own copy of the counter and each request using
different instances of the servlet.  Your session is not necessarily
tied to one instance of a servlet.

JavaWorld Article on Thread-Safe Servlets
http://www.javaworld.com/javaworld/jw-07-2004/jw-0712-threadsafe.html


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.