Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Threads
Search Coderanch
Advanced search
Google search
Register / Login
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
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Devaka Cooray
Tim Cooke
Jeanne Boyarsky
Ron McLeod
Sheriffs:
Saloon Keepers:
Piet Souris
Bartenders:
Forum:
Threads and Synchronization
java threads
jignesh soni
Ranch Hand
Posts: 155
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
which are the two threads always running in java ?
Norm Radder
Rancher
Posts: 5153
38
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I give up.
Is it the white one and the black one?
Ulf Dittmer
Rancher
Posts: 43081
77
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Here's some code that will come in handy if you want to investigate what threads are active at any given time.
private void getThreadInfo (PrintWriter output) { // Get the top level thread group ThreadGroup adam = getAdam(Thread.currentThread().getThreadGroup()); // Get the count of active threads in the system int num = adam.activeCount(); // Get all of the active threads in the system Thread list[] = new Thread[num]; int x = adam.enumerate(list); // if (x != num) //return; // Display all of the active threads in the system output.println("<p><b>Threads</b><table border=1><tr>"); output.println("<th>Group</th><th>Name</th><th>Priority</th><th>Daemon</th><th>Alive</th></tr>"); for (int i = 0; i < x; i++) { if (list[i] == null) continue; String threadName = list[i].getName(); String groupName = list[i].getThreadGroup().getName(); output.println("<tr><td>" + groupName + "</td><td>" + threadName + "</td><td>" + list[i].getPriority() + "</td><td>" + (list[i].isDaemon() ? "Yes" : "No") + "</td><td>" + (list[i].isAlive() ? "Yes" : "No") + "</td></tr>"); } output.println("</table>"); } // Recursively calls itself to find the top level thread group private ThreadGroup getAdam (ThreadGroup tg) { ThreadGroup parent = tg.getParent(); if (parent == null) return tg; return getAdam(parent); }
Nitesh Kant
Bartender
Posts: 1638
I like...
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Alternatively, take a thread dump(CTRL-Break(Win systems) or CTRL-/(Unix)) and find it for yourself how many threads are alive and they are in what states!!
apigee
, a better way to API!
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
threads
Two threads of same class instance to wait separately
New to using a profiler .Please help
Threads
Synchronized methods
More...