A simple solution in Java
\nclass Foo {\n    \n    CountDownLatch second;\n    CountDownLatch third;\n\n    public Foo() {\n        second = new CountDownLatch(1);\n        third = new C
```\nclass Foo {\n    \n    CountDownLatch second;\n    CountDownLatch third;\n\n    public Foo() {\n        second = new CountDownLatch(1);\n        third = new CountDownLatch(1);\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        second.countDown();\n    }\n\n    public void second(Runnable printSecond) throws InterruptedException {\n        second.await();\n        // printSecond.run() outputs "second". Do not change or remove this line.\n        printSecond.run();\n        third.countDown();\n    }\n\n    public void third(Runnable printThird) throws InterruptedException {\n        third.await();\n        // printThird.run() outputs "third". Do not change or remove this line.\n        printThird.run();\n    }\n}\n```
['Java']