+ pthread_attr_t a;
+ int min_prio, max_prio, p;
+ struct sched_param sp;
+
+ if (p_internal->state != STATE_IDLE)
+ return wxTHREAD_RUNNING;
+
+ // Change thread priority
+ pthread_attr_init(&a);
+ pthread_attr_getschedpolicy(&a, &p);
+
+ min_prio = sched_get_priority_min(p);
+ max_prio = sched_get_priority_max(p);
+
+ pthread_attr_getschedparam(&a, &sp);
+ sp.sched_priority = min_prio +
+ (p_internal->prio*(max_prio-min_prio))/100;
+ pthread_attr_setschedparam(&a, &sp);
+
+ // this is the point of no return
+ p_internal->state = STATE_RUNNING;
+ if (pthread_create(&p_internal->thread_id, &a,
+ wxThreadInternal::PthreadStart, (void *)this) != 0)
+ {
+ p_internal->state = STATE_IDLE;
+ pthread_attr_destroy(&a);
+ return wxTHREAD_NO_RESOURCE;
+ }
+ pthread_attr_destroy(&a);
+
+ return wxTHREAD_NO_ERROR;