Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is object publishing and why do we need it?

Tags:

java

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.

like image 460
Roadrunner Avatar asked Nov 05 '11 10:11

Roadrunner


People also ask

What is object in publishing?

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.

What is publish in Java?

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.


1 Answers

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.

like image 71
Tom Anderson Avatar answered Sep 24 '22 01:09

Tom Anderson