Merge pull request #8 from Globostofo/patch-thread

Put attendant thread in background
This commit is contained in:
Romain CLEMENT 2023-10-17 20:50:57 +02:00 committed by GitHub
commit 6aaaba3eb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -74,7 +74,10 @@ void attendant()
int main() int main()
{ {
print("Car wash opening with " << N << " waiting spaces"); print("Car wash opening with " << N << " waiting spaces");
thread attendantThread(attendant); thread attendantThread(attendant);
attendantThread.detach();
vector<thread> cars {}; vector<thread> cars {};
for(size_t i = 0; i < N+1; ++i) for(size_t i = 0; i < N+1; ++i)
{ {
@ -82,7 +85,6 @@ int main()
cars.push_back(std::move(t)); cars.push_back(std::move(t));
} }
attendantThread.join();
for (auto &car: cars) { for (auto &car: cars) {
car.join(); car.join();
} }