QOS Class not getting set for pthread in macOS

I am building a macOS project where I m creating a thread using pthread in cpp. I am setting the QOS class using the pthread_attr_set_qos_class_np and later checking the value of the QOS class using the pthread_attr_get_qos_class_np. These calls are successful but the QOS class is not being set. Below is the cpp function that I m invoking from my swift code.

bool CppThread::CreateThread ()
{
        pthread_t      threadId;
        pthread_attr_t attr;
        qos_class_t    qos_class;
        int            relative_priority;
    
    int rc = pthread_attr_init(&attr);
    if (rc) {
        
        printf ("pthread_attr_init failed");
    }

    if (pthread_attr_set_qos_class_np (&attr, QOS_CLASS_BACKGROUND, 5)) {
        
        printf ("pthread_attr_set_qos_class_np failed\n");
    }

    int retval = pthread_create(&threadId, &attr, threadFunction, NULL);
    if (retval) {
        std::cerr << "Error creating thread" << std::endl;
        return false;
    }

    if (pthread_attr_get_qos_class_np (&attr, &qos_class, &relative_priority)) {
        
        printf ("pthread_attr_get_qos_class_np failed\n");
    }

    printf ("QoS class: %d, Relative priority: %d\n", qos_class, relative_priority);
    
    pthread_join(threadId, NULL);  // Wait for thread to finish
    std::cout << "Thread finished" << std::endl;

    return true;
}

OUTPUT:

QoS class: 0, Relative priority: 0

Thread finished

I have tried setting multiple QOS values but the output always shows the QOS class value as 0. Why is it not getting set?