You are calling pthread_setschedprio(thread1,2);
when thread1
hasn't been initialized to a valid value. You can set the priority for a thread only after the thread has been created.
To be clear, you should indicate whether or not commenting out the call to pthread_setschedprio(thread1,2)
enables the program to run without crashing. (Also - do you really want the colon in the scanf()
format string?)