Hello!
I have a problem with threads. I want make something like this:
void myFunc() {
std::cout << "Works!";
for(;;); // loop waiting for something
}
while(1) {
if(sth) {
sf::Thread t(&myFunc);
t.launch();
}
}
Now it will create 1 thread and while will stop. If in myFunc() won't be for() it works good. Help my please.
I have main() -> create thread sth observator -> if observator gets what want it create some threads...But now create only one ;c
I don't know, maybe I'm stupid...
// ===== RESOLVED
sf::Thread *th;
for(int i=0; i<10; i++) {
th = new sf::Thread(&func, i);
th->launch();
}
th->wait();
Rly, I'm stupid..