Java Many Readers One Writer with semaphores and multithreading
0
$begingroup$
I've been looking for a solution to the may readers one writer in Java. I was intrigued by this question posted here and I read the wikipedia entry about it. So far, I've reached a fine solution, or at least thats what I think. I've setup a new github repo to put the code to be used in another proyects if people want But I'm open to improvements and critics if you see fit The pseudocode of the main class is here abstract class AbsrtactReadersWriter<T> { Semaphore readCountSempaphote = new Semaphore(1); Semaphore resourceSemaphore = new Semaphore(1, true); Semaphore serviceQueueSemaphore = new Semaphore(1,true); AtomicInteger readCount = new AtomicInteger(0); public final T read() { T data = null; try { // Entry to read serviceQueueSe