! 4 space instead of tab & remove global std
[scx.git] / tests / thread.cpp
blob671a5babe267c4cb50f1d40a315e39a48d476477
1 #include "scx/Thread.hpp"
2 #include <iostream>
3 using namespace std;
4 using namespace scx;
6 void hello(int a, int b)
8 cout << a*b << endl;
12 class test
14 public:
15 test(char ch):
16 mCh(ch)
20 void print(int a)
22 for (size_t i = 0; i < 100; ++i)
24 cout << mCh;
26 cout << endl << a << endl;
29 private:
30 char mCh;
33 int main()
35 test a('a');
36 test b('b');
37 test c('c');
38 Function<void (int)> f1(&test::print, &a);
39 Function<void (int)> f2(&test::print, &b);
40 Function<void (int)> f3(&test::print, &c);
42 Thread th1(f1, 1);
43 Thread th2(f2, 2);
44 Thread* th3 = new Thread();
45 th3->Run(f3, 3);
47 cout << th1.GetId() << endl;
48 cout << th2.GetId() << endl;
49 cout << th3->GetId() << endl;
51 th1.Join();
52 th2.Join();
53 th3->Join();
54 delete th3;
57 //Function<void (int, int)> f4(&hello);
58 Thread th4;
59 th4.Run(Function<void (int, int)>(&hello), 4, 5);
60 th4.Detach();
61 sleep(2);
63 cout << endl;
65 return 0;