I start my thread like this:
os_thread_return_t sequence() {
while(;;){
System.println("test");
}
}
Thread *mythread = new Thread("sample", sequence);
Stop the thread like this:
mythread ->dispose();
mythread = NULL;
This works on my photon, with multiple threads running at the same time. But when I run the code on my electron, things get really weird.
In my thread I push some things over MQTT. On my electron, nothing gets through. When I pull out my usb cable (and the battery is still connected), suddenly MQTT publishes the first message it tried to send. (but all the messages later also don’t get through)
Is there a difference in implementation of Thread between photon and electron?
FreeRTOS threads are not to be killed or disposed. Once they are created they should live forever.
BTW that tight loop with Serial.print()
hammers the shared resource way toooooooooooo violently.
Okay, but this is a simplified example. My threading don’t use the Serial.print() like this, it uses MQTT and some other logic + some delays.
On the photon, everything works fine. My question is if there are different implementations between the photon and electron?
When I pull out my usb cable -> sends 1-4 messages and stops… When I put it back in -> same thing…
When I push a MQTT message to my electron that triggers the electron to connect to the particle cloud -> when connecting -> sends a couple of messages…
It’s like it switches threads on these triggers and then is stuck again.