How to make it with std::thread (GenerateRSAKey)

I have no idea how to use threads but I need to process it with big numbers.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
  void Source::GenerateRSAKey()
{
	cout << "Minél nagyobb prímet adjon meg!\n";
	int counter_t = 0;
	do
	{
		if (counter_t > 0)
			cout << "A fő kulcs túl kicsi adjon meg nagyobb prímeket!\n";
		
		cout << "Adja meg az első prímet:\t";
		getline(cin, prime_one); //2
		while (!IsPrime(prime_one))
		{
			cerr << "Nem prím adja meg újra:\t";
			getline(cin, prime_one);
		}
		cout << "Adja meg az második prímet:\t";
		getline(cin, prime_two); //7
		while (!IsPrime(prime_two))
		{
			cerr << "Nem prím adja meg újra:\t";
			getline(cin, prime_two);
		}
		++counter_t;
		product = BigInteger(prime_one) * BigInteger(prime_two);
	} while (!MinAscii(BigInteger(product)));

	lambda = (BigInteger(prime_one) - BigInteger(1)) * (BigInteger(prime_two) - BigInteger(1));
	string encryprion, decryption, mainkey;
	
	BigInteger bigLambda = BigInteger(lambda);
	BigInteger one = BigInteger(1);
	for (BigInteger i = BigInteger(2); i < BigInteger(lambda); ++i)
	{
		if (GCD(i, bigLambda) == one)
		{
			encryprion = i;
			break;
		}
	}
        /*
	vector<thread> threads_vector;
	bool found = false;
	BigInteger start = BigInteger(2);
	BigInteger threadSpread = bigLambda / BigInteger(5);
	BigInteger new_end = BigInteger(2) + threadSpread - BigInteger(1);
	for (BigInteger x = BigInteger(0); x < BigInteger(5); x++) 
	{
		thread th(&Source::GCDForThreads, start, new_end, bigLambda, found);
		threads_vector.push_back(move(th));

		start += threadSpread;
		new_end += threadSpread;
	}

	for (auto& thr : threads_vector) 
	{
		thr.join();
	}*/

	string saved_for_decryptionkey = "";
	for (BigInteger i = BigInteger(1); i < BigInteger(lambda); ++i)
	{
		if ((BigInteger(encryprion) * i) % BigInteger(lambda) == 1)
		{
			saved_for_decryptionkey = i;
			break;
		}
	}

	int random = 1 + rand() % max_push; //max_push == 5
	BigInteger BI = BigInteger(random) * BigInteger(lambda);
	decryption = BigInteger(saved_for_decryptionkey) + BI;

	mainkey = product;

	cout << "A kódoláshoz a kulcsok:\t\t" << encryprion << "\t" << mainkey << endl;
	cout << "A dekódoláshoz a kulcsok:\t" << decryption << "\t" << mainkey << endl;
}
The BigInteger is a class to use big numbers,
GCD is the greatest common divisor for BigInteger class,
and what I would need is in the 2 'for's to be able to find the first good i value as fast as possible.

Sorry to bother anyone with this simple question but i never learned multithreading.
Topic archived. No new replies allowed.