Question by Alex: Using semaphores in Java? How can I make threads run at different frequencies to one another?
I have three different threads running in my Java program. One prints “1″, another “2″, and the last “3″. I need to make the “1″s and “2″s print less frequently than the “3″, using semaphores, but I’m very stuck. Any ideas?

Best answer:

Answer by McFate
You could wait on one semaphone between all three threads, and then:

(1) Print “3″ every time you get the semaphore in the “3″ thread
(2) Print “1″ only every second or third time you get the semaphore in the “1″ thread

Add your own answer in the comments!