Index: src/examples/thread.c
===================================================================
--- src/examples/thread.c	(revision eb2e723e2366bc9652cf9888645a9249f5fd129a)
+++ src/examples/thread.c	(revision 8f49a54ffd2ebee0164eb91c530d7625a9d1f910)
@@ -1,67 +1,47 @@
-// #include <kernel>
+#include <fstream>
 #include <stdlib>
 #include <threads>
 
-// // Start coroutine routines
-// extern "C" {
-//       forall(dtype T | is_coroutine(T))
-//       void CtxInvokeCoroutine(T * this);
+// Start coroutine routines
+struct MyThread {
+	thread_h t;
+	unsigned id;
+	unsigned count;
+};
 
-//       forall(dtype T | is_coroutine(T))
-//       void CtxStart(T * this, void ( *invoke)(T *));
+DECL_THREAD(MyThread)
 
-// 	forall(dtype T | is_coroutine(T))
-//       void CtxInvokeThread(T * this);
-// }
+void ?{}( MyThread * this, unsigned id, unsigned count ) {
+	this->id = id;
+	this->count = count;
+}
 
-// struct MyThread {
-// 	thread_h t;
-// 	unsigned id;
-// 	unsigned count;
-// };
+void main(MyThread* this) {
+	sout | "Thread" | this->id | " : Suspending" | this->count | "times" | endl;
+	suspend();
 
-// void ?{}( MyThread * this ) {
-// 	this->id = 0;
-// 	this->count = 10;
-// }
+	for(int i = 0; i < this->count; i++) {
+		sout | "Thread" | this->id | " : Suspend No." | i + 1 | endl;
+		suspend();
+	}
+}
 
-// void ?{}( MyThread * this, unsigned id, unsigned count ) {
-// 	this->id = id;
-// 	this->count = count;
-// }
+int main(int argc, char* argv[]) {
 
-// void ^?{}( MyThread * this ) {}
+	unsigned itterations = 10;
+	if(argc == 2) { 
+		int val = ato(argv[1]);
+		assert(val >= 0);
+		itterations = val;
+	}
 
-// void main(MyThread* this) {
-// 	printf("Main called with %p\n", this);
-// 	printf("Thread %d : Suspending %d times\n", this->id, this->count);
+	sout | "User main begin" | endl;
 
-// 	for(int i = 0; i < this->count; i++) {
-// 		printf("Thread %d : Suspend No. %d\n", this->id, i + 1);
-// 		printf("Back to %p\n", &this->t.c);
-// 		suspend();
-// 	}
-// }
+	{
+		thread(MyThread) thread1 = { (unsigned)1, itterations };
+		thread(MyThread) thread2 = { (unsigned)2, itterations };
+	}
 
-// thread_h* get_thread(MyThread* this) {
-// 	return &this->t;
-// }
-
-// coroutine* get_coroutine(MyThread* this) {
-// 	return &this->t.c;
-// }
-
-int main() {
-	printf("Main is %p\n", this_coroutine());
-
-	// thread(MyThread) thread1;
-	// thread(MyThread) thread2;
-
-	// thread2.handle.id = 1;
-
-
-	// // kernel_run();
-
-	// printf("Kernel terminated correctly\n");
+	sout | "User main end" | endl;
 
 	return 0;
