Skip to content

Commit f0b0597

Browse files
committed
add first code example.
1 parent 94c52fe commit f0b0597

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

code/chapter1/hello-world/Makefile

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
}

0 commit comments

Comments
 (0)