I'm just looking the pattern for high performance for the following scenario :
We've N threads that are doing some processing, during this processing it's possible that we need to execute a 'special'code that has been encapsulated in a Java class. The objects are not thread safe, but I can have M of those to be executed in parallel.
So from N threads I'm calling a pool of M objects.
thread 1 :
doing thinks
PoolObject -> Object1.execute() // no synchronize
thread 2 :
doing thinks
PoolObject -> Object2.execute() // no synchronize
thread n :
doing thinks
PoolObject -> wait object is available
PoolObject -> Object2.execute()
ArrayBlockingQueue is an implementation that could be used but it's using a ReentrantLock ( aka synchronize ). It's a solution like ConcurrentHashMap that uses compareAndSwapLong like mechanism.
Is there some existing code for executing this in high performance scenario like ConcurrentHashMap ?