How to set priority with updated thread model on a running thread


In the updated thread model setPriority is now protected, what is the intended way to change a currently running thread’s priority?


I don’t think it’s possible to change the priority while a thread is running and as far as I know, it never was, even though the software design would have allowed it.

We used to have juce::thread::setCurrentThreadPriority, and the current model permits changing the priority in a derived class via the protected juce::thread::setPriority member, so I think we should be able to do it still but not if we aren’t running as a derived class.

Oh, you are correct. I was thinking of this:

        Note that this priority can only be set **before** the thread has
        started. Switching to this priority, or from this priority to a different
        priority, is not supported under Android and will assert.

        For best performance this thread should yield at regular intervals
        and not call any blocking APIs.

        @see startThread, setPriority, sleep, WaitableEvent
        realtimeAudioPriority = -1