File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Number of threads accessing a Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Number of threads accessing a Servlet" Watch "Number of threads accessing a Servlet" New topic
Author

Number of threads accessing a Servlet

shivang sarawagi
Ranch Hand

Joined: Jun 19, 2008
Posts: 147
I have a code for calculating the number of threads accessing a servlet at an instance, but i have two doubts in code

here is the code



1. What is happening in this line of code



the put method maps the key to the values in a hashtable but in this case why is "this,this" used.

2. Why is the hashtable declared as static

Thanks
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19543
    
  16

That map is not counting threads, it's counting servlet instances. Your web container may create only one single instance that will handle all requests. It also does not count actual instances, only instances that are accessed. If a servlet instance is never accessed this code will never be called.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Number of threads accessing a Servlet
 
Similar Threads
about threading in servlet.
Doubt in reDirect and post
HttpSession doubt
Access counter for servlets
Code Review - ChatServlet