hey, I am trying solving the phiplosopher dinning problem, and this is my code
but there is a dead lock, the log shows
Copy code
Philosopher2 takes left fork 2
Philosopher0 takes left fork 0
Philosopher1 takes left fork 1
Philosopher3 takes left fork 3
Philosopher4 takes left fork 4
The dining philosophers problem is designed to demonstrate deadlocks like this. Do you have a solution in mind that you're trying to implement in Kotlin, or are you just asking about how to solve the deadlock in general? If it's the latter, you need to start by studying the existing material that's been written about this problem, rather than asking here.
k
kurt_steiner
01/27/2024, 8:48 AM
actually I have solve it in java using the lock, but I want to use coroutines, so I ask it here