During one of my job interviews for Java Developer I was asked a question:
What is object publishing and why do we need it?
And I'm not sure I know the right answer:
I think that object publishing is is when the object (variable) state is put to heap memory. And it's needed for objects (variables) sharing between threads.
Am I right? Please correct me if I'm wrong. I've been searching the Java Language Specification, but found nothing that would unambiguously answer this question.
Hint: The question is deliberately formed in non strict and exact way - that's the catch of it.
Each text box, line, graphic, header, etc,. is an object in Publisher. All objects have several characteristics that enable them to be changed in regards to position, size, stacking arrangement, and to sometimes change the contents inside the object.
To publish Java methods, you write call specs. For a given Java method, you declare a function or procedure call spec using the SQL CREATE FUNCTION or CREATE PROCEDURE statement. Inside a PL/SQL package or SQL object type, you use similar declarations.
Your answer was pretty close. I would define object publication as the act by one thread of making a reference to an object visible to another thread. Usually, this is connected with object creation: you need to ensure that a newly-created object is published in such a way that the other thread will see it in an initialised state.
The classic text on this (and many other thread-related matters) is Java Concurrency in Practice. If you don't have a copy of that, and can't be bothered to google up a pirated PDF, not that i would suggest you do that, and indeed even if you do or can, you should heed the mighty CERT Oracle Secure Coding Standard for Java's advice that you Do not publish partially initialized objects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With