In this example two threads make two LEDs blink. The first one changes state two times every second while the second one is set "high" only when the on-board user button is pressed (the discovery's blue button).
Miosix provides two different interfaces for creating a thread: the `pthread` API and a navite one. Here we will consider only the native one.
Miosix provides two different interfaces for creating and managing threads: the `pthread` API and a navite one. Here we will consider only the native one.
In order to spawn a new thread, the `create()` function is needed and it takes the following parameters
*`startfunc`: the entry point function for the thread. It is the function that will be executed by the thread.
...
...
@@ -11,6 +7,10 @@ In order to spawn a new thread, the `create()` function is needed and it takes t
*`argv`: a `void*` pointer that is passed as a parameter to the entry point function.
*`options`: thread options, such ad `Thread::JOINABLE`. By default native threads are not joinable, which means they will never end. The `join()` method allows to wait for a thread to end its execution.
### Multithreaded LED Blink
In this example two threads make two LEDs blink. The first one changes state two times every second while the second one is set "high" only when the on-board user button is pressed (the discovery's blue button).