import java.util.*; import java.util.concurrent.*; public class MultipleInstance { static final int MaxCustomerCount=3; static Container container=new Container(); static Customer customerList[]=new Customer[MaxCustomerCount]; static String customerNames[]={ "Lenova", "IBM","Intel"}; static float customerBalances[]={5000.0f, 5000.0f, 5000.0f}; static int ThreadRunningTimes=10; static CyclicBarrier barrier=new CyclicBarrier(2); static MyThread thread0; static MyThread thread1; static int finished=0; public static void main(String args[]) { init(); thread0=new MyThread(0); thread1=new MyThread(1); thread0.start(); thread1.start(); Customer trouble=new Customer("Lenova", -5000.0f); while (finished<2) { try { Thread.sleep(1000); System.out.println("let trouble starts here and see if IBM is still 5000.0"); container.addCustomer(trouble); container.getCustomer("IBM").display(); container.removeCustomer(trouble); } catch(Exception er) { } } System.out.println("if synchronized keyword can apply to multiple instance, then "+ " the balance should be 5000+10*50*2=6000 and let's see how much it is:"); container.getCustomer("IBM").display(); } static void init() { for (int i=0; i