C : semaphore-based - simple and short
\ntypedef struct {\n    sem_t sem_a;\n    sem_t sem_b;\n} Foo;\n\nFoo* fooCreate() {\n    Foo* obj = malloc(sizeof (Foo));\n    sem_init(&obj->sem_a, 0, 0);\n  
```\ntypedef struct {\n    sem_t sem_a;\n    sem_t sem_b;\n} Foo;\n\nFoo* fooCreate() {\n    Foo* obj = malloc(sizeof (Foo));\n    sem_init(&obj->sem_a, 0, 0);\n    sem_init(&obj->sem_b, 0, 0);\n    return obj;\n}\n\nvoid first(Foo* obj) {\n    printFirst();\n    sem_post(&obj->sem_a);\n}\n\nvoid second(Foo* obj) {\n    sem_wait(&obj->sem_a);\n    printSecond();\n    sem_post(&obj->sem_b);\n}\n\nvoid third(Foo* obj) {\n    sem_wait(&obj->sem_b);\n    printThird();\n}\n\nvoid fooFree(Foo* obj) {\n    free(obj);\n}\n```
['C']