Mavzu: Parallel dasturlash. Parallel dasturlash paradigmalari


Download 17.5 Kb.
bet4/4
Sana14.01.2023
Hajmi17.5 Kb.
#1093502
1   2   3   4
Bog'liq
2-mustaqil ish

4-Misol

#include


#include
using namespace std;
void printStr(char * str) {
cout << str << '\n';
}
void printArray(int a[],const int len) {

for (int i = 0; i < len; i++) {


cout << a[i] << ' '; }
}
int main() {

char* str = "thread function with parametrs"; const int len = 8;


int arr[len] = {12, 45, -34, 57, 678, 89, 0, 1};
thread func_thread(printStr, str);
thread func_thread2(printArray, arr, len);
if (func_thread.joinable()) func_thread.join();
if (func_thread2.joinable()) func_thread2.join();


return 0; }
Download 17.5 Kb.

Do'stlaringiz bilan baham:
1   2   3   4




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling