[infinispan-dev] deadlock detection - coin toss

Mircea Markus mircea.markus at jboss.com
Wed Jul 8 14:24:46 EDT 2009


David M. Lloyd wrote:
> On 07/08/2009 11:11 AM, Mircea Markus wrote:
>> this is regarding: http://tinyurl.com/nunmyu
>> In order to be able to determine which tx should commit and which 
>> will rollback, I need to generate a coin toss for each node - a 
>> random number.
>> In order to do that I'm thinking to use on of the following:
>>
>> 1) use java.util.Random . The issue with this class is that it has an 
>> undocumented behavior when it comes to concurrent access, so I cannot 
>> rely on it behaving correctly if  I don't  enforce proper 
>> synchronization. I'm afraid this might become a bottleneck as all the 
>> prepapares requests might want to synchronize on it.
>
> What about a ThreadLocal<Random>?  Should be quick-ish
>
> - DML
I don't have control over the calling thread, so cannot do the cleanup 
properly. Thanks for the idea!




More information about the infinispan-dev mailing list