This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Garbage Collector Threads

 
Alim Atar
Ranch Hand
Posts: 102
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,

Regards,
Alim
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Alim Atar
Ranch Hand
Posts: 102
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks lot Peter for your nice answers.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic