• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Thread

 
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is from a Mock.
Which of the following statements are NOT true about Java garbage collection Thread?
A) The garbage collection thread has a low priority
B) The garbage collection thread can be invoked at any time
c) A call to System.gc() is guaranteed to invoke garbage collection thread immediately
d) A call to Runtime.getRuntime().gc() is guaranteed to invoke garbage collection thread immediately
The correct answers are B, C, D.
I think the answer should be C,D.
We can invoke the GC thread any time using System.gc(). Am I wrong?
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
System.gc() and Runtime.getRuntime().gc() can only SUGGEST the JVM to run the Garbage Collector Thread.
There is NO WAY for the programmer to EXPLICITLY INVOKE the Garbage Collector !!!
[ January 03, 2003: Message edited by: Vijay Albuquerque ]
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Vijay, I think the posters is referring to the fact code can call the System.gc(), but that doesnt mean that garbage collection actually takes place at that time. I agree that the method can be invoked through the code, but it wont guarantee that the garbage collection thread is actually run... so the question should probably be rephrased.
 
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sarma Lolla:
Which of the following statements are NOT true about Java garbage collection Thread?
A) The garbage collection thread has a low priority
B) The garbage collection thread can be invoked at any time
c) A call to System.gc() is guaranteed to invoke garbage collection thread immediately
d) A call to Runtime.getRuntime().gc() is guaranteed to invoke garbage collection thread immediately
The correct answers are B, C, D.
I think the answer should be C,D.
We can invoke the GC thread any time using System.gc(). Am I wrong?


When yo ucompare B and C or D, you will find:
1) call to System.gc()
and
2) invoke garbage collection
mean different things.
You can do (1) anytime, but (2) is never guaranteed. So B is wrong.
 
High Plains Drifter
Posts: 7289
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree with Kevin; the wording is ambiguous and leaves the "correct" answer up to interpretation. The right answer seems to reside in the mind of the questioner and not on paper, where it belongs.
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No matter how you look at it, this question is bound to confuse someone. Yes, call to System.gc() and "invoke garbage collection" may mean different things (you can also argue that instead of "call" you can replace with "invoke" - invoke system.gc(), which will confuse people even more), but the fact that it is confusing still remains. The question shouldn't be about who has better interpritiation of English language, but rather should be about the knowledge about Java and every nuiance that they may wish to test on.
reply
    Bookmark Topic Watch Topic
  • New Topic