unsigned RainbowTable::findPasswordByHash(unsigned* hash) {
    int i;
    Chain resultChain;
    vector<vector<string> > result;

    ThreadPool* myPool = new ThreadPool(THREADS_COUNT);
    myPool->initializeThreads();

    for (i = CHAIN_LENGTH - 1; i >= 0; --i) {

        PasswordFindWorkerThread* myThread =
                new PasswordFindWorkerThread(i, hash);
        myPool->assignWork(myThread);

        if (PasswordFindWorkerThread::result != 0) {
            break;
        }

    }

    myPool->destroyPool(1);
    delete myPool;

    printf("false alarm count: %d\n",
            PasswordFindWorkerThread::falseAlarmCount);

    if (PasswordFindWorkerThread::result != 0) {
        return PasswordFindWorkerThread::result;
    }

    return 0;
}
void RainbowTable::generateTable(unsigned generateTableRecordsCount) {
    puts("Generate Table::start");

    unsigned i;

    ThreadPool* myPool = new ThreadPool(THREADS_COUNT);
    myPool->initializeThreads();

    for (i = 0; i < generateTableRecordsCount; i++) {
        ChainGeneratingWorkerThread* myThread =
                new ChainGeneratingWorkerThread(i);
        myPool->assignWork(myThread);
    }

    myPool->destroyPool(1);
    delete myPool;

    puts("Generate Table::finish");
}