I should have been more specific, notification delivery is not guaranteed. From http://download.oracle.com/javase/6/docs/api/java/lang/management/MemoryPoolMXBean.html:
 
"There is no guarantee about when the MemoryMXBean will emit a threshold notification and when the notification will be delivered. "
 
> Date: Fri, 14 Jan 2011 15:46:02 +0100
> From: bban@redhat.com
> To: infinispan-dev@lists.jboss.org
> Subject: Re: [infinispan-dev] ISPN-863 - Thoughts / Questions
>
>
>
> On 1/14/11 3:32 PM, david marion wrote:
> >
> >
> > I agree. There are two ways to determine what the memory usage is, polling or notifications. The notification mechanism is not guaranteed
>
>
> Are you referring to MemoryMXBean / MemoryPoolMXBean ? What do you mean
> by not guaranteed ? Are you suggesting the notfications are not
> implemented by all JVM vendors ?
>
>
> > so we could have a background thread that polls to determine whether or not the threshold has been passed. Then in the put and replace methods, it would be the cost of checking a boolean value.
>
> When notifications are available, we should use them, otherwise polling
> would be fine, I guess.
>
>
> --
> Bela Ban
> Lead JGroups / Clustering Team
> JBoss
> _______________________________________________
> infinispan-dev mailing list
> infinispan-dev@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/infinispan-dev