I have 2 threads, which communicate via a message queue.
If i do the following:
Messenger mess = new Messenger(); //Create an object of type Messenger
....
controller.enqueue(mess); //Adds it's reference to a message queue from another thread
....
mess = new Messenger(); //Create another object of type Messenger
....
controller.enqueue(mess); //Adds it's reference AS WELL to the message queue of another thread
My QUESTION here is:
Will this work? Will the message queue from controller have 2 objects in it? (in fact 2 references to the 2 objects)? Or will there be only one, the second one? Does the second object creation override the first one somehow?
The
enqueuemethod receives two different references to two different objects. If the method does what its name and the name of the class promises, then the queue will indeed have two objects enqueued.