I am trying to write a program which implements a solution for the Prisoners and switches problem. I created a SwitchRoom class..
public class SwitchRoom
{
private boolean switchA;
private boolean switchB;
and a prisoner class
public class Prisoner
{
public void visitSwitchRoom() {
// do something with switches
Now I am thinking how exactly I can run this. Would it be best to have Prisoner class implement Runnable (make instances of them into threads) and then spawn 23 threads in a java program?
If this is a good approach could you please provide a code sample to get me started?
If it is not the right way could you give me some pointers on what is?