This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Collection: Understanding WeakHashMap

 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the following example am I correct in saying that the assertion can fail,
because the WeakHashMap referenced by m2 could lose its contents, if there is some massive garbage collection taking place?

Thanks
-Barry
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. if the WeakHashMap contains the only reference to an object, then that object is eligible for GC.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic