/** * Copyright (c): Uwe Schmidt, FH Wedel * * You may study, modify and distribute this source code * FOR NON-COMMERCIAL PURPOSES ONLY. * This copyright message has to remain unchanged. * * Note that this document is provided 'as is', * WITHOUT WARRANTY of any kind either expressed or implied. */ /** 4 theads sharing 1 buffer resource * for demonstrating wait and notify */ //---------------- public class SyncTest2 { public static Resource buffer = new Resource(); //---------------- public static void main(String[] argv) { Thread [] threads = { new Producer(buffer), new Producer(buffer), new Consumer(buffer), new Consumer(buffer) }; String [] names = { "producer1", "producer2", "consumer1", "consumer2" }; for (int i = 0; i < threads.length; ++i) { threads[i].setName(names[i]); threads[i].start(); } } }