- alive=1;
- pthread_create(&the_thread, 0, wrapper, this);
-}
+ if (alive)
+ {
+ eDebug("thread already running !!");
+ return;
+ }
+ pthread_attr_t attr;
+ pthread_attr_init(&attr);
+ if (prio||policy)
+ {
+ struct sched_param p;
+ p.__sched_priority=prio;
+ pthread_attr_setschedpolicy(&attr, policy );
+ pthread_attr_setschedparam(&attr, &p);
+ }
+ if ( pthread_create(&the_thread, &attr, wrapper, this) )
+ {
+ eDebug("couldn't create new thread");
+ return;
+ }
+ pthread_attr_destroy(&attr);
+ usleep(1000);
+ int timeout=20;
+ while(!alive && timeout--)
+ {
+ eDebug("waiting for thread start...");
+ usleep(1000*10);
+ }
+ if ( !timeout )
+ eDebug("thread couldn't be started !!!");
+}