Multithreading and timeout functionality.