RAD Studio |  |

Overriding the Default Priority
See Also
Collapse All

When the amount of CPU time the thread should receive is implicit in the thread's task, its priority is set in the constructor. This is described in Initializing the thread. However, if the thread priority varies depending on when the thread is executed, create the thread in a suspended state, set the priority, and then start the thread running:

Copy Code

    SecondThread :=  TMyThread.Create(True); { create but don't run }
    SecondThread.Priority := tpLower; { set the priority lower than normal }
    SecondThread.Resume; { now run the thread }

Copy Code

    TMyThread *SecondThread = new TMyThread(true); // create but don't run
    SecondThread->Priority = tpLower; // set the priority lower than normal
    SecondThread->Resume(); // now run the thread

See Also

Starting and Stopping Threads

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!