Thread example using mbed 5.7

Revision:
0:83abbbeb9a3d
Child:
1:bbbe0fae16f3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Jan 13 18:26:10 2018 +0000
@@ -0,0 +1,32 @@
+// Simple Example fo use of Threads on mbed OS 5
+//   Only need to include mbed.h
+
+#include "mbed.h"
+
+// Variable for a second thread
+Thread thread;
+
+DigitalOut ledA(LED1); // Red LED
+DigitalOut ledB(LED2); // Green LED
+
+// This method is run in the second thread
+void ledB_thread() {
+    while (true) {
+        Thread::wait(250);
+        ledB = !ledB;
+    }
+}
+
+// This is the main thread
+int main (void) {
+    ledA = 1 ; // off
+    ledB = 1 ; // off
+    
+    // start the second thread
+    thread.start(callback(ledB_thread));
+
+    while (true) {
+        Thread::wait(400);
+        ledA = !ledA;
+    }
+}