Как из pthread выполнить функцию в главный поток

Как из pthread выполнить функцию в главный поток. У меня есть вот такой код:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>

FILE* file;
void* thr() {
    ftruncate(fileno(file),5);
    fflush(file);
}
int main() {
    file = fopen("file.txt", "w");

    pthread_t tid;
    pthread_create(&tid,NULL,thr,NULL);
    ftruncate(fileno(file),10);
    fflush(file);
    pthread_join(tid,NULL);

}

Мне нужно чтоб из thr() в определённый момент приостановить основной, а потом в другом моменте запустить


Ответы (0 шт):