Hallo! Ich habe mir eine einfache Threadklasse gebaut, wie nachstehend, die unter Windows (GCC Codeblocks) auch wunderbar funktioniert. Wenn ich den gleichen Code versuche auf einem µCLinux-System (ARM11) zu compilieren und laufen zu lassen scheint die Applikation an der Stelle obj->Execute(); abzustürzen. Hat jemand eine Idee woran das liegen könnte? Stefan
1 | #include <iostream> |
2 | #include <conio.h> |
3 | #include <pthread.h> |
4 | #include <windows.h> |
5 | |
6 | using namespace std; |
7 | |
8 | class PThread |
9 | {
|
10 | private:
|
11 | pthread_t thread; |
12 | public:
|
13 | virtual void Execute(void) = 0; |
14 | PThread(void); |
15 | };
|
16 | |
17 | static void *execute(void *arg) |
18 | {
|
19 | PThread *obj = (PThread*) arg; |
20 | obj->Execute(); |
21 | return 0; |
22 | }
|
23 | |
24 | PThread::PThread(void) |
25 | {
|
26 | pthread_create(&thread, NULL, &execute, this); |
27 | }
|
28 | |
29 | class MyThread: public PThread |
30 | {
|
31 | public:
|
32 | void Execute(void); |
33 | };
|
34 | |
35 | void MyThread::Execute(void) |
36 | {
|
37 | while (1) |
38 | {
|
39 | cout << "Execute" << endl; |
40 | Sleep(1000); |
41 | }
|
42 | }
|
43 | |
44 | int main() |
45 | {
|
46 | MyThread mythread; |
47 | getch(); |
48 | return 0; |
49 | }
|