user15428: Well I've just started learning the concept of multithreading with C++ and immediately a bunch of questions came to mind about the possibility of using multithreading with microcontrollers in general and Arduino specifically.
So, is it possible to use multithreading on any type of Arduino boards?

user13594: I use Atomthreads on Atmega128, it is very lightweight with minimum overhead. Have task scheduler, mutex, semaphores and queue. Code is portable but might require some configuration to use with Arduino IDE (I use Atmel Studio). I primarily use task scheduler, never had problems. Just checked, the development is still active.

user10907: The really quick answer is "maybe" – it depends on what you mean by "Arduino" and what you mean by "thread." The answer is likely to be different for the AVR based Arduinos (Uno et al.) vs. the ARM based Arduinos (Due et al.) – I would expect there to be much better hardware support for "real" threads on the ARM processors. Another question you'd want to answer is "why threads?" Do you want the abstraction to help you organize your code? Or do you actually need "real" threads?
Before there was hardware thread support (e.g., the mid-80s) there are user thread implementations, it seems possible that they might be adaptable to run even on an AVR. I would expect it to be something of a project.
There is a threads package called Protothreads which may be interesting. The description says "Protothreads are extremely lightweight stalkless threads designed for severely memory constrained systems." I found another question asking about simple usage of Protothreads, so it seems that you may find some other users of the package.
You may also find some useful information in this Stack Exchange question on threads, a quick search for "C user threads" found this implementation on the first page – and I'm sure there are many more.
A search on "Arduino threads" found several more interesting looking links:

How can I create multiple running threads?
Arduino Thread package on GitHub
http://www.kwartzlab.ca/2010/09/arduino-multi-threading-librar/
http://forums.trossenrobotics.com/showthread.php?5923-Multithreading-(Parallel-loops)-on-an-Arduino

If you just want threads, a small and inexpensive board, and I/O pins it might be worth considering a Raspberry Pi – Linux has thread support.

user4628: There's one Arduino-like product that certainly could enable multi-threading, as it is multi-core: the Shield Buddy TC275.

So basically you have three setup() functions, and three loop() functions. True multi-threading.

user13432: In Cosa you can find the following support for concurrent programming:

Events, interface interrupt service routines 
Jobs, delayed, periodic or alarm functions with us, ms and seconds level timers (Watchdog, RTT or RTC).
FSM, object-state function
ProtoThreads, object-state pointer
Threads, Semaphores, etc, multiple stacks
UML Capsules and Connectors, dependency driven programming

There are plenty examples on how to use these. A good starting point is the Blink sketches. There is even a multi-threading Blink example with a thread that does the LED on/off and a controller thread that periodically changes the blink period. The thread stack size is only 64 bytes and it runs even on an ATtiny. 
With all the AVR internal hardware modules (such as SPI, TWI, UART, etc) there is plenty of opportunities for concurrency.  
A Scheduler library for the Arduino core is also available. This is a port of the Cosa Threads. Please see github for further details. 
Cheers!

15428: <p>Well I've just started learning the concept of multithreading with C++ and immediately a bunch of questions came to mind about the possibility of using multithreading with microcontrollers in general and Arduino specifically.</p>

<p>So, is it possible to use multithreading on any type of Arduino boards?</p>
 13594: <p>I use <a href="https://www.google.mn/url?sa=t&amp;source=web&amp;rct=j&amp;url=http://atomthreads.com/&amp;ved=0ahUKEwizhomMgsrRAhXMHZQKHV74DcAQFggYMAA&amp;usg=AFQjCNGsxGMmrzZ5XhSCrSidilYeNhcdwg&amp;sig2=EUhC4i0J711ypa5OhK2o7g" rel="nofollow noreferrer">Atomthreads</a> on Atmega128, it is very lightweight with minimum overhead. Have task scheduler, mutex, semaphores and queue. Code is portable but might require some configuration to use with Arduino IDE (I use Atmel Studio). I primarily use task scheduler, never had problems. Just checked, the development is still active.</p>
 10907: <p>The really quick answer is "maybe" – it depends on what you mean by "Arduino" and what you mean by "thread." The answer is likely to be different for the AVR based Arduinos (Uno et al.) vs. the ARM based Arduinos (Due et al.) – I would expect there to be much better hardware support for "real" threads on the ARM processors. Another question you'd want to answer is "why threads?" Do you want the abstraction to help you organize your code? Or do you actually need "real" threads?</p>

<p>Before there was hardware thread support (e.g., the mid-80s) there are user thread implementations, it seems possible that they might be adaptable to run even on an AVR. I would expect it to be something of a project.</p>

<p>There is a threads package called <a href="http://dunkels.com/adam/pt" rel="nofollow noreferrer">Protothreads</a> which may be interesting. The description says "Protothreads are extremely lightweight stalkless threads designed for severely memory constrained systems." I found <a href="https://arduino.stackexchange.com/questions/12411/arduino-protothreads-by-example">another question asking about simple usage</a> of Protothreads, so it seems that you may find some other users of the package.</p>

<p>You may also find some useful information in this Stack Exchange <a href="https://stackoverflow.com/questions/9145321/implementing-a-user-level-threads-package">question on threads</a>, a quick search for "C user threads" found <a href="http://homepage.cs.uiowa.edu/~jones/opsys/threads" rel="nofollow noreferrer">this implementation</a> on the first page – and I'm sure there are many more.</p>

<p>A search on "Arduino threads" found several more interesting looking links:</p>

<ul>
<li><a href="https://arduino.stackexchange.com/questions/286/how-can-i-create-multiple-running-threads">How can I create multiple running threads?</a></li>
<li><a href="https://github.com/ivanseidel/ArduinoThread" rel="nofollow noreferrer">Arduino Thread package on GitHub</a></li>
<li><a href="http://www.kwartzlab.ca/2010/09/arduino-multi-threading-librar/" rel="nofollow noreferrer">http://www.kwartzlab.ca/2010/09/arduino-multi-threading-librar/</a></li>
<li><a href="http://forums.trossenrobotics.com/showthread.php?5923-Multithreading-(Parallel-loops)-on-an-Arduino" rel="nofollow noreferrer">http://forums.trossenrobotics.com/showthread.php?5923-Multithreading-(Parallel-loops)-on-an-Arduino</a></li>
</ul>

<p>If you just want threads, a small and inexpensive board, and I/O pins it might be worth considering a Raspberry Pi – Linux has thread support.</p>
 4628: <p>There's one Arduino-like product that certainly could enable multi-threading, as it is multi-core: the <a href="https://www.rs-online.com/designspark/bringing-multicore-to-the-arduino-world-with-shieldbuddy-tc275" rel="nofollow noreferrer">Shield Buddy TC275</a>.</p>

<p><a href="https://i.stack.imgur.com/RUu3B.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RUu3B.jpg" alt="Core setup and loop functions"></a></p>

<p>So basically you have three <code>setup()</code> functions, and three <code>loop()</code> functions. True multi-threading.</p>
 13432: <p>In <a href="https://github.com/mikaelpatel/Cosa" rel="nofollow noreferrer">Cosa</a> you can find the following support for concurrent programming:</p>

<ol>
<li><a href="https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/Event.hh" rel="nofollow noreferrer">Events</a>, interface interrupt service routines </li>
<li><a href="https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/Job.hh" rel="nofollow noreferrer">Jobs</a>, delayed, <a href="https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/Periodic.hh" rel="nofollow noreferrer">periodic</a> or <a href="https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/Alarm.hh" rel="nofollow noreferrer">alarm</a> functions with us, ms and seconds level timers (Watchdog, RTT or RTC).</li>
<li><a href="https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/FSM.hh" rel="nofollow noreferrer">FSM</a>, object-state function</li>
<li><a href="https://github.com/mikaelpatel/Cosa/blob/master/libraries/ProtoThread/ProtoThread.hh" rel="nofollow noreferrer">ProtoThreads</a>, object-state pointer</li>
<li><a href="https://github.com/mikaelpatel/Cosa/blob/master/libraries/Nucleo/Thread.hh" rel="nofollow noreferrer">Threads</a>, Semaphores, etc, multiple stacks</li>
<li><a href="https://github.com/mikaelpatel/Cosa-UML" rel="nofollow noreferrer">UML</a> Capsules and Connectors, dependency driven programming</li>
</ol>

<p>There are plenty examples on how to use these. A good starting point is the <a href="https://github.com/mikaelpatel/Cosa/tree/master/examples/Blink" rel="nofollow noreferrer">Blink</a> sketches. There is even a <a href="https://github.com/mikaelpatel/Cosa/blob/master/examples/Blink/CosaBlinkThread/CosaBlinkThread.ino" rel="nofollow noreferrer">multi-threading Blink</a> example with a thread that does the LED on/off and a controller thread that periodically changes the blink period. The thread stack size is only 64 bytes and it runs even on an ATtiny. </p>

<p>With all the AVR internal hardware modules (such as SPI, TWI, UART, etc) there is plenty of opportunities for concurrency.  </p>

<p>A <a href="https://github.com/mikaelpatel/Arduino-Scheduler" rel="nofollow noreferrer">Scheduler</a> library for the Arduino core is also available. This is a port of the Cosa Threads. Please see github for further details. </p>

<p>Cheers!</p>
