3 ms·
I wrote a lock free algorithm. Every thread monitors every other thread's thread Id and the lowest thread Id wins. When a thread finishes its work it updates t
by samsquire 4y ago
I wrote a lock free algorithm.
Every thread monitors every other thread's thread Id and the lowest thread Id wins. When a thread finishes its work it updates the thread Id to Integer.MAX_INTEGER so someone else can have a go.
Readers block writers and writer's block readers so it's not very good. But it's a start.
It's hard to update a linked list as you could accidentally partially update it while it is being iterated. I could allow parallel edits and reads if the read is after the edit. So I would need to introduce a different variable for checking while reading. It needs to be logically after the write.
HTTPS://GitHub.com/samsquire/compare-and-swap-sort