/
bvs22
/
draft
Обзор
Документация
Войти
/
bvs22
/
draft
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
threads/parallel_output.c
39 строк
630 B
Batomunkuev Vladimir
Решение первой задачи на параллельный вывод
25 ноя 2024, 17:40
25 ноя 2024, 17:40
197c06e
Код
Авторство
О чём код?
#include <stdio.h> #include <pthread.h> #include <unistd.h> void* print_num(void* arg) { for(int i = 1; i <= 10; i++) { printf("%d ", i); sleep(1); } pthread_exit(NULL); } void* print_letters(void* arg) { for(int i = 65; i <= 74; i++) { printf("%c ", i); sleep(1); } pthread_exit(NULL); } int main() { pthread_t thread1; pthread_t thread2; pthread_create(&thread1, NULL, print_num, NULL); pthread_create(&thread2, NULL, print_letters, NULL); pthread_join(thread1, NULL); pthread_join(thread2, NULL); printf("\n"); return 0; }