Multi-thread programming with Cpy is quit easy. Just import the thread module, then use thread.start_new_thread(func, args) to run a function as a thread.
import time; import thread; function run(){ while(true){ printf("thread: %d says hello\n", thread.get_ident()); time.sleep(1); } } foreach(range(0, 3) as i){ args = tuple(); thread.start_new_thread(run, args); } // press Enter to quit stdin.readline();
Output:
thread: 5032 says hello thread: 4708 says hello thread: 5676 says hello thread: 5032 says hello thread: 4708 says hello thread: 5032 says hello ...