• Post Reply Bookmark Topic Watch Topic
  • New Topic

Number of threads accessing a Servlet  RSS feed

 
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 21378
92
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
You are HERE! The other map is obviously wrong. Better confirm with this tiny ad:
Why should you try IntelliJ IDEA ?
https://coderanch.com/wiki/696337/IntelliJ-IDEA
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!