I created a preemptive threading library for the Teensy 3.x and am releasing it here in case anyone needs it and for comments and suggestions. It's a first release, so I would expect some bugs.

Source code: https://github.com/ftrias/TeensyThreads

Direct link to ZIP: https://github.com/ftrias/TeensyThre...er/Threads.zip

This library follows the strategy recommended in the Corex-M4 reference guide. It uses the built-in threading support of the Teensy's Cortex-M4 to implement basic threading. It supports a Teensy-like interface and a minimal std::thread interface from the C++11 standard. More technical information in the source code.

Examples:

Code:
#include <Threads.h>
volatile int count = 0;
void thread_func(int data){
  while(1) count += data;
}
void setup() {
  threads.addThread(thread_func, 1);
}
void loop() {
  Serial.println(count);
}
Using std::thread

Code:
#include <Threads.h>
volatile int count = 0;
void thread_func(int data){
  while(1) count += data;
}
void setup() {
  std::thread th1(thread_func, 1);
  th1.detach();
}
void loop() {
  Serial.println(count);
}
This project came about because I was coding a Teensy application with multiple things happening at the same time and really missed
multithreading available in other OSs. I searched for threading systems, but found nothing.

This combined with boredom and excess free time led to complete overkill for the solution and thus the implementation of simple threads.

For more info and documentation see the Git repository.