1、C++开辟线程
//编写线程函数TakeProc1 DWORD WINAPI TakeProc1(LPVOID lpParam) { //编写操作代码 return 0; } //线程ID DWORD dwThreadId1; //开启线程 HANDLE hThread1 = CreateThread(NULL, 0, TakeProc1, NULL, 0, &dwThreadId1); //关闭线程 CloseHandle(hThread1);
2、python开辟线程
import threading t1 = threading.Thread(target=fly1) # 向函数传递参数 # t1 = threading.Thread(target=fly1,args=(13,)) t2 = threading.Thread(target=fly2) # 两个线程同时运行 t1.start() t2.start() # 1运行完2运行 # t1.start() # t1.join() # t2.start()