Easy Java Solution
\nclass Foo {\n\n        private final CountDownLatch firstLatch;\n        private final CountDownLatch secondLatch;\n\n        public Foo() {\n            firs
```\nclass Foo {\n\n        private final CountDownLatch firstLatch;\n        private final CountDownLatch secondLatch;\n\n        public Foo() {\n            firstLatch = new CountDownLatch(1);\n            secondLatch = new CountDownLatch(1);\n        }\n\n        public void first(Runnable printFirst) throws InterruptedException {\n            printFirst.run();\n            firstLatch.countDown();\n        }\n\n        public void second(Runnable printSecond) throws InterruptedException {\n            firstLatch.await();\n            printSecond.run();\n            secondLatch.countDown();\n        }\n\n        public void third(Runnable printThird) throws InterruptedException {\n            secondLatch.await();\n            printThird.run();\n        }\n    }\n```
['Java']