I read that when sending an object to the function/another object, not the actual object is sent, but his copy. So, when multithreading, I have a ArrayBlockingQueue with size of one, and two classes -- Producer and Consumer (which are extensions of Thread), which read and write the data, accordingly, this way:
ArrayBlockingQueue<Integer> queue = new ArrayBlockingQueue<Integer>();
Producer add = new Producer(queue);
Consumer show = new Consumer(queue);
I'm not sending to the constructors the "queue" variable itself, but the copy of it. So, both of objects have different queues, so there's not going to be any misunderstanding between these two objects, right? If yes, why do we need thread synchronization? If no, why?