The higher the time-sharing thread's priority value, the greater the chance that it will be the next thread to run. A real-time thread is executed as soon as it's ready. If more than one real-time thread is ready at the same time, the thread with the highest priority is executed first. This function takes information about the thread's scheduling and CPU needs, and returns a reasonable priority value to use when spawning the thread. The semaphore mechanism is described in great detail in Semaphores.
Synchronization is sometimes a side-effect of sending data between threads.
To override this behavior, you can install your own signal handlers. This may seriously cripple any threads that linger beyond the death of the main thread. It's possible to create an application in which the main thread sets up one or more other threads, gets them running, and then dies. But such applications should be rare. In general, you should try to keep your main thread around until all other threads in the team are dead.