C++, 一段码如何改成使用thread的代码

我这儿有段C++的小程序,它可以解一个加密文件的密码,两位数的密码,比如说给一个文档加一个两位数的密码,可以使用这个猜出着两位数的密码。我想请教如何将这段码改成使用thread的C++程序

#include <iostream>
#include <cstdlib>
#include <string>

using namespace std;

#include "guesser.h"
#include "generator.h"

// Call as "pgm filename"
int main(int argc, char **argv)
{
    if(argc != 2) {
        cout << "Usage: " << argv[0] << " encryptedfile" << endl;
        exit(1);
    }

    // 创建猜想对象并打开加密文件。
    guesser trythis;
    if(!trythis.open(argv[1])) {
        cout << "Unable to read " << argv[1] << endl;
        exit(2);
    }

    // 计算解码次数。
    int nkey = 0;

    // 尝试密码,知道成功打开文件。
    generator gen("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
              "0123456789");
    string outfile = argv[1] + string(".plain");
    while(true) {
        string keyguess = gen.next();
        guesser::guess_t res = trythis.guess(keyguess, outfile);
        if(res == guesser::no || res == guesser::no_but_wrote) {
            if((++nkey & 0xffff) == 0) {
                cout << nkey << " keys; current "
                     << keyguess << endl;
            }
            continue;
        } else if(res == guesser::yes) {
            cout << "The key is " << keyguess << ", " 
                 << nkey << " keys guessed." << endl;
            exit(0);
        } else {
            cout << "Unable to process guess " << keyguess << endl;
            exit(1);
        }
    }
}

如何将这段码改成使用thread的C++程序

你是想将你的解密操作放到一个单独的线程中去吗?_beginthreadex()