好玩的代码之C++实现CPU满载
#include <windows.h> #include <iostream> #include <cstdlib> using namespace std; DWORD WINAPI FunProc(LPVOID lpParameter) { float * p; while (p == p) { (*p++)+1.144564542315345; } return 0; } int main(int argc, char **argv) { HANDLE hThread; for (int i = 0; i < 4; i++) { hThread = CreateThread(NULL, 0, FunProc, &i, 0, NULL); CloseHandle(hThread); } system("pause"); return 0; }