C++ (Qt)// thread 2while (true) { theSemaphore.acquire(); ...} // thread 1..theSemaphore.release();
глобально:QAtomicInt buffer;поток 1:char tmp;char = getchar();buffer.fetchAndStoreOrdered(tmp);поток 2:while(1){ if(buffer != -257) { std::cout<<buffer; buffer.fetchAndStoreOrdered(-257); }}