Threads implementation.