一、手动
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/32624cf14f003b7589df54308cd20f2d.png)
二、自动
#include<windows.h>
#include<iostream>
using namespace std;
DWORD WINAPI myfun(LPVOID lpParameter);
int main()
{
SYSTEM_INFO SystemInfo;
GetSystemInfo(&SystemInfo);
SystemInfo.dwNumberOfProcessors;
cout<< SystemInfo.dwNumberOfProcessors<<endl;
HANDLE h0, h1 ,h2, h3;
h0 = CreateThread(NULL, 0, myfun, NULL, 0, NULL);
h1 = CreateThread(NULL, 0, myfun, NULL, 0, NULL);
h2 = CreateThread(NULL, 0, myfun, NULL, 0, NULL);
h3 = CreateThread(NULL, 0, myfun, NULL, 0, NULL);
SetThreadAffinityMask(h0, 0x00000001);
SetThreadAffinityMask(h1, 0x00000002);
SetThreadAffinityMask(h2, 0x00000003);
SetThreadAffinityMask(h3, 0x00000004);
CloseHandle(h1);
CloseHandle(h2);
CloseHandle(h0);
CloseHandle(h3);
Sleep(-1);
return 0;
}
DWORD WINAPI myfun1(LPVOID lpParameter)
{
return 100000 * 10000;
}