File tree 2 files changed +48
-0
lines changed
code/chapter1/hello-world
2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ all :hello-world
2
+
3
+ CC =g++
4
+ CPPFLAGS =-Wall -std=c++11 -ggdb
5
+ LDFLAGS =-pthread
6
+
7
+ hello-world :hello-world.o
8
+ $(CC ) $(LDFLAGS ) -o $@ $^
9
+
10
+ hello-world.o :hello-world.cc
11
+ $(CC ) $(CPPFLAGS ) -o $@ -c $^
12
+
13
+ .PHONY :
14
+ clean
15
+
16
+ clean :
17
+ rm hello-world.o hello-world
Original file line number Diff line number Diff line change
1
+ /*
2
+ * ========================================================================
3
+ *
4
+ * Filename: hello-world.cc
5
+ *
6
+ * Description: std::thread hello world example.
7
+ *
8
+ * Created: 09/14/2013 09:41:12 AM
9
+ *
10
+ * Author: Fu Haiping (forhappy), [email protected]
11
+ * Company: ICT ( Institute Of Computing Technology, CAS )
12
+ *
13
+ * ========================================================================
14
+ */
15
+
16
+ #include < cstdio>
17
+ #include < cstdlib>
18
+ #include < iostream> // std::cout
19
+ #include < thread> // std::thread
20
+
21
+ void thread_task () {
22
+ std::cout << " hello thread" << std::endl;
23
+ }
24
+
25
+ int main (int argc, const char *argv[])
26
+ {
27
+ std::thread t (thread_task);
28
+ t.join ();
29
+
30
+ return EXIT_SUCCESS;
31
+ }
You can’t perform that action at this time.
0 commit comments