Open farmerbriantee opened 2 years ago
I've run into some interesting behaviour. My code only works if I run the two threads both in threads. running one in the thread and one in the setup does not work. Do you know if the init is also in a thread?
I'm doing this and it doesn't work:
void Task1code() {
while(true) {
//doing some stuff here in a loop
}
}
void Task2code() {
while(true) {
//doing some other stuff here in a loop
}
}
setup()
{
threads.addThread(Task2code, 1);
Task1code();
}
and thus I have to do this
setup()
{
threads.addThread(Task2code, 1);
threads.addThread(Task1code, 1);
while(true)
delay(100);
}
I would like to avoid using extra threads
This isn't an issue, but felt it was worth mentioning. I am pretty sure it isn't in the documentation that as soon as you add a thread then the main "Loop" is also a thread and now is limited to the timeslice default. If 99% of your code is in main loop and you add a thread that can run continuous, it now uses half the processor time.
Great library, but perhaps include that the traditional Arduino "Loop" function now becomes thread 0 and may require much more timeslice from the default. Thank you for the excellent library.