What am I doing wrong here?
ipmcc opened this issue · comments
Starting from the example in the readme I did this. It doesn't work. Can anyone tell me why?
#include <TeensyThreads.h>
volatile int count = 0;
std::mutex foo;
void thread_func(int data){
Threads::Scope scope(foo);
while(1) count += data;
}
void setup() {
std::thread th1(thread_func, 1);
th1.detach();
}
void loop() {
Threads::Scope scope(foo);
Serial.println(count);
}
Edit: Never mind. I'm dumb. I'd delete this, but I can't figure out how. The trick is that "threads" work like threads and not like the loop()
method.