cleanup
This commit is contained in:
parent
a335828778
commit
c92bff3c23
@ -3,18 +3,6 @@
|
|||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QCoreApplication>
|
#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 {
|
struct IPrintable {
|
||||||
~IPrintable() = default;
|
~IPrintable() = default;
|
||||||
|
|
||||||
@ -89,7 +77,6 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
//QCoreApplication app(argc, argv);
|
|
||||||
|
|
||||||
QSemaphore lockC(1);
|
QSemaphore lockC(1);
|
||||||
QSemaphore lockBC(0);
|
QSemaphore lockBC(0);
|
||||||
@ -105,6 +92,6 @@ int main(int argc, char *argv[]) {
|
|||||||
t1.wait();
|
t1.wait();
|
||||||
t2.wait();
|
t2.wait();
|
||||||
t3.wait();
|
t3.wait();
|
||||||
//return app.exec();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user