Unified single- and multithreaded code.