Download c source code

main:
	shared male_queue := semaphore(0)
	shared female_queue := semaphore(0)

	while true:
		case read_char() of:
			'M': create_thread(male)
			'W': create_thread(female)
			EOF: return

male:
	signal(male_queue)
	wait(female_queue)
	dance()

female:
	signal(female_queue)
	wait(male_queue)
	dance()