my dog learned polymorphism
The moose likes Performance and the fly likes Garbage Collector Threads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "Garbage Collector Threads" Watch "Garbage Collector Threads" New topic

Garbage Collector Threads

Alim Atar
Ranch Hand

Joined: Oct 06, 2006
Posts: 102

Hello All,

I have some questions about GC threads,

1) Are Garbage collector threads(many invloed in collection) GREEN threads?

2)Does java1.6/1.7 support Greent threads?
If YES then how we can create GREEN threads?
If NO then why java stopped supporting GREEN threads?(just an overview)

3) Can we create more GC Threads ? Strange question but idea might be very useful in case of memory centric applications.

Hoping for answer ranchers,



Peter Johnson

Joined: May 14, 2008
Posts: 5852

1) All threads, including GC threads, are native OS threads. At least for the Sun JVM, and I suspect for other JVMs as well.

2) I do not think so.

3) Use this option: -XX:ParallelGCThreads=N where N is the desired number of threads. Starting with JVM 5, if your system has at least 2 CPUs (or cores) and at least 2GB of RAM, then the JVM will automatically run a parallel collector for the young generation. It will assign 1 thread for each CPU up to 8, then 5 threads for every 8 CPUs after that. I suggest that you never run more GC threads than you have CPUs otherwise the collection will run slower due to the context switching among threads.

JBoss In Action
Alim Atar
Ranch Hand

Joined: Oct 06, 2006
Posts: 102

Thanks lot Peter for your nice answers.
I agree. Here's the link:
subject: Garbage Collector Threads
jQuery in Action, 3rd edition