好玩的代码之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;
}

 

posted @ 2015-06-05 16:28  冷冰若水  阅读(1706)  评论(0编辑  收藏  举报