From a3eb5dd684a6ff157f8a8d0592792c124c68522e Mon Sep 17 00:00:00 2001 From: Erik Strand <erik.strand@cba.mit.edu> Date: Sun, 25 Nov 2018 15:52:26 -0500 Subject: [PATCH] Add simplest possible std::thread example --- Makefile | 7 +++++++ thread.cpp | 13 +++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 Makefile create mode 100644 thread.cpp diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7c3bb10 --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +# This Makefile compiles and flashes four different programs: + +CPPFLAGS=-Wall -O3 -pthread + +%: %.cpp + g++ $(CPPFLAGS) -o build/$@ $< + diff --git a/thread.cpp b/thread.cpp new file mode 100644 index 0000000..94ab3f5 --- /dev/null +++ b/thread.cpp @@ -0,0 +1,13 @@ +#include <thread> +#include <iostream> + +void thread_method() { + std::cout << "hello thread" << std::endl; +} + +int main() { + std::thread thread(thread_method); + thread.join(); + return 0; +} + -- GitLab