Code example for Exchanger

		// Creates two buffers 
		List<String> buffer1=new ArrayList<>();
		List<String> buffer2=new ArrayList<>();
		// Creates the exchanger 
		Exchanger<List<String>> exchanger=new Exchanger<>();
		// Creates the producer 
		Producer producer=new Producer(buffer1, exchanger);
		// Creates the consumer 
		Consumer consumer=new Consumer(buffer2, exchanger);
		// Creates and starts the threads 
		Thread threadProducer=new Thread(producer);
		Thread threadConsumer=new Thread(consumer);
Stop searching for code, let great code find you!  Add Codota to your java IDE