linux线程调度 和 优先级的问题

我创建了两个线程,一个线程不断输出A,另一个线程不断输出B,两个线程同时运行时AB间断打印,现在我想要通过修改 线程调度策略 以及线程的优先级来达到 两个线程都被创建后只有一个线程占据 CPU资源,我的代码如下:
设置线程的调度策略为FIFO并且设置不同的优先级,但是并不能达到效果。


#include
#include
#include
#include

void* thread(void *arg) {
    char ch = *(char *)arg;
    
    while(1) {
        printf("%c",ch);
        fflush(stdout);
        //sleep(1);
    }
}

int main(int argc, char *argv[]) {
    pthread_t t1, t2;
    char ch1 = 'A', ch2 = 'B';
    pthread_attr_t attr;
    struct sched_param sch;

    pthread_attr_init(&attr);
    pthread_attr_getschedparam(&attr, &sch);
    
    sch.sched_priority = 10;
    pthread_attr_setschedpolicy(&attr, SCHED_FIFO);
    pthread_attr_setschedparam(&attr, &sch);
    pthread_create(&t1, &attr, thread, (void*)&ch1);
    
    sch.sched_priority = 10;
    pthread_attr_setschedparam(&attr, &sch);
    pthread_create(&t2, &attr, thread, (void*)&ch2);

    pthread_join(t1, NULL);
    pthread_join(t2, NULL);

    return 0;
}

http://t.zoukankan.com/kuangke-p-9621523.html