Helper for multithreaded programming