Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Finding number of threads spawned  RSS feed

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wanted to test the threadpool programme available in informit site [http://www.informit.com/articles/article.asp?p=30483].

Here are my questions:

1.How do i test the number of thread spawned ?
2.I configured it to use only 10 Threads,whereas on using getCount() it shows more than 10.How is that possible ?
3.On looking at the TaskManager in windows XP os it shows more.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JVM spawns quite a few threads just for its own upkeep. So even if you don't start any, you can still see a bunch running.

That article is out of date. As of Java 5 we have good thread pooling in the library. Look at Executor in the doc or the SUN Concurrency Tutorial for details.

Also see JConsole in Java 5 and later. It has good information on threads and you can use the same APIs that it uses to get the same information in your programs.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!