Threads exercise. Print alternatively the ids of two distinct threads. : //A programme which creates 2 threads that print their own ID and then finish.  
// Be careful at printing the threads alternatively (A, B, A, B, ...).

// Here is my code:


    void *funct();
    //void *functz();
    //int functie=0;
    
    pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
    pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER;
    
    int main(){
            int rc1, rc2;
            pthread_t thread1, thread2;
    
    	if( (rc1 = pthread_create(&thread1, NULL, &funct, NULL)) )
            {
                    printf("Eroare la creare thread: %d \n", rc1);
            }
            if( (rc2 = pthread_create(&thread2, NULL, &funct, NULL)) )
            {
                    printf("Eroare la creare thread: %d \n", rc2);
            }
            pthread_join (thread1, NULL);
            pthread_join (thread2, NULL);
    
            return 0;
    }
    
    void *funct()
    {
            int i;
          	//pthread_mutex_lock(&mutex1);
            for( i=0; i<10; i++)
            {
     		//pthread_mutex_lock(&mutex1);
    		//pthread_mutex_lock(&mutex2);
                    printf("Thread ID: %li \n", pthread_self() );
                    
    		//pthread_mutex_unlock(&mutex2);
    		//pthread_mutex_unlock(&mutex1);
            }
    	//pthread_mutex_unlock(&mutex1);
    }
    /*
    void *functz()
    {
            int i;
          	//pthread_mutex_lock(&mutex1);
            for( i=0; i<10; i++)
            {
     		pthread_mutex_lock(&mutex2);
    		
                    printf("Thread ID: %li \n", pthread_self() );
                  
    		pthread_mutex_lock(&mutex1);	
           }
    */

//As you can see, I have tried multiple strategies, but none of them was successful. 