main_headless.c: Use multi-threading