Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Number of Thread  RSS feed

 
Nimish Patel
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

one simple java programe prints "hello world".
so how many threads work in this programe ?

please advise me.

Thanks.

rgds,
Nimish
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, for most intents and purposes, your Hello World program has one Java thread.

However, it is not as simple as that. The Java Virtual Machine typically runs several other threads for its own purposes. These threads will show up if you look at the Java process with some system tool, like Windows Task Manager or Unix "top". But as an application programmer, you almost never care about these other threads.

Why do you want to know?
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have JDK 5 look at the JConsole tool on a simple running program. Put yours in a loop or sleep or something to keep it running. You'll probably be surprised to see the number of other threads running. The good news is you can usually ignore them unless you want to hack the JVM or something radical.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!