//--------------------------------------------------------- // com_pthread.cc //--------------------------------------------------------- #include #include #include const std::size_t N = 64; char msg[N] = {'\0'}; void *escritor(void *) { std::iota(msg, msg + 'z' - 'a' + 1, 'a'); std::cout << "writer: " << msg << std::endl; return nullptr; } void *lector(void *) { std::cout << "reader: " << msg << std::endl; return nullptr; } int main() { pthread_t e, l; pthread_create(&e, nullptr, escritor, nullptr); pthread_join(e, nullptr); pthread_create(&l, nullptr, lector, nullptr); pthread_join(l, nullptr); }