Thread Safty w/ WeakReferences

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • iLL
    New Member
    • Oct 2006
    • 63

    Thread Safty w/ WeakReferences

    Okay... I've got a question about weak references

    Is it possible for the clear() method to be called by the garbage collector when there is still a strong reference in the system?

    I'm specifically concerned about the following scenario:

    1. The GC finds no strong reference and decides to clear the weak reference object
    2. A context switch occurs and GC stops executing
    3. The get() method is called and returns a value
    4. A context switch occurs and GC starts executing
    5. GC calls clear()

    Is this possible?
Working...