This commit is contained in:
Robin Dietzel 2023-12-09 13:22:46 +01:00
parent a335828778
commit c92bff3c23

View File

@ -3,18 +3,6 @@
#include <QThread>
#include <QCoreApplication>
/*
* Barlas Chpt 3 Ex 12:
Create three threads, each printing out the letters A, B, and C.
The printing must adhere to these rules:
The total number of Bs and Cs that have been output at any
point in the output string cannot exceed the total number
of As that have been output at that point.
After a C has been output, another C cannot be output until
one or more Bs have been output.
Use semaphores to solve the problem.
*/
struct IPrintable {
~IPrintable() = default;
@ -89,7 +77,6 @@ protected:
int main(int argc, char *argv[]) {
//QCoreApplication app(argc, argv);
QSemaphore lockC(1);
QSemaphore lockBC(0);
@ -105,6 +92,6 @@ int main(int argc, char *argv[]) {
t1.wait();
t2.wait();
t3.wait();
//return app.exec();
return 0;
}