#include "thread/QueuedThread.h" #include "thread/Blocker.h" #include #include static const int COUNT = 3; static const int SLEEP_US = 200*1000; void task(void* arg); int main() { QueuedThread* thread = createQueuedThread(); postQueuedTask(thread, &task, NULL); postQueuedTask(thread, &task, NULL); for (int i = 0; i < COUNT*2+1; i++) { printf("Main: %d\n", i); usleep(SLEEP_US); } joinQueuedThread(thread); freeQueuedThread(&thread); return 0; } // --- void task(void* arg) { (void)arg; for (int i = 0; i < COUNT; i++) { printf("Thread: %d\n", i); usleep(SLEEP_US); } }