views:

57

answers:

1

First some background: In Java all the constructs for conditional waiting allows for spurious wakeups which can mess with fairness. I've been toying with writing an implementation for a ReadWrite lock which serves the incoming threads in strict order-of-arrival.

Now, my algorithm creates a new java.util.concurrent.Condition each time a thread enters the class I've written. I wonder whether this kind of behavior is advisable or if there are some bad side effects of this kind of patterns, like massive slowdown.

+1  A: 

Well, like all performance issues you should generally try it the clean way first and then test. That being said creating and GCing short lived objects – even a lot of them – is what JVMs are particularly good at.

Jed Wesley-Smith