Java fastest using volatile boolean and while poll
\nclass Foo {\n    volatile boolean waitTwo = true;\n    volatile boolean waitThree = true;\n\n    public Foo() {\n        \n    }\n\n    public void first(Runn
```\nclass Foo {\n    volatile boolean waitTwo = true;\n    volatile boolean waitThree = true;\n\n    public Foo() {\n        \n    }\n\n    public void first(Runnable printFirst) throws InterruptedException {\n        \n        // printFirst.run() outputs "first". Do not change or remove this line.\n        printFirst.run();\n        waitTwo = false;\n    }\n\n    public void second(Runnable printSecond) throws InterruptedException {\n        \n        while(waitTwo){}\n        \n        // printSecond.run() outputs "second". Do not change or remove this line.\n        printSecond.run();\n        waitThree = false;\n    }\n\n    public void third(Runnable printThird) throws InterruptedException {\n        \n        while(waitThree){}\n        \n        // printThird.run() outputs "third". Do not change or remove this line.\n        printThird.run();\n    }\n}\n```
[]