
I have an application (a video player), that uses three threads to play videos (one thread handles decoding, another video display, and another audio). These threads have a thread barrier to wait until all 3 threads finish. This works fine. Now, my video player supports playing back two movies at the same time (to have one as a background and one as a foreground). Currently this is done with the same code for both. My problem is that there's no sync between the two movies and I am puzzled on how to achieve synchronism. I am unsure whether a thread barrier can be waited twice by two threads or whether I should have a single barrier that waits on the 6 threads ( 2 decode, 2 video, 2 audio ). If someone has any insight, it would be appreciated.