This chain of atoms, the lock, the latch, the signals, the latches, the threads … might be a lot of fun for some, but for really fast computing, you need a new mindset:
Imagine a box full of snakes on top. And now they crawl around – one on top of the other and the other under the other, you can put obstacles inside them, they crawl around without stopping crawling and never crashing. You throw food into it and some snakes will eat it, “cure” it. Statistically everyone is always full and always has something to eat.
Nota Pen: No snake stops crawling. No queue “blocks” another queue, no queue “waits” to clear * for something * another queue.
Here’s an interesting video on the topic: https://youtube.com/watch? V = rXC5n4svNXo
And now comes the homework: implementation in code.
Enjoy!
Note: There is a programming language that deeply accommodates this “mentality”. In all libraries rewritten specifically for this purpose!