Multi-threaded applications

example:

Two threads to write a thread print integer of 1-52, another thread printing letters AZ. The print order 12A34B56C ... 5152Z. I.e., in ascending order of the print integers and letters, and each of the two integers after printing, print a
letter, alternating cycles print until the end of the letter Z and the integer 52.
Requirements:
1) preparation of the printing Printer class, declare private property index, the initial value 1, used to indicate how many times the print.
() Method waits 2) prepared by numbers printed in the printing method Printer class print (int i), with a multiple of 3 to wait, using the wake up threads waiting notifyAll

Code Example:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/LuJunlong/p/12157250.html