• Post Reply Bookmark Topic Watch Topic
  • New Topic

Finding number of threads spawned

 
Nagarajan Krishnamurthy
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.
 
Stan James
(instanceof Sidekick)
Ranch Hand
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!