在Linux C++里,用thread让程序更快的运行

我这儿有段码,它可以解一个加密文件的密码,两位数的密码,比如说给一个文档加一个两位数的密码,可以使用这个猜出着两位数的密码。我想问的是怎样使用thread对他稍微改变使他在解码的时候更快速一点。谢谢各位大神!!!

 #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);
        }
    }
}

解码这是CPU密集型的,主要取决于性能,而不是调度,你需要能够优化算法,或者用GPU等来加速运算等