Hi Paul,

Thanks for explanation and suggestions.

I updated the webrev to use instance methods and fields and using synchronized.
(And a bit of long-line cleanup.)

webrev:
   http://cr.openjdk.java.net/~rriggs/webrev-orb-addrinuse-8168613/

Thanks, Roger


On 10/25/2016 5:18 PM, Paul Sandoz wrote:
On 25 Oct 2016, at 13:50, Roger Riggs <[email protected]> wrote:

Hi,

On 10/25/2016 4:31 PM, Paul Sandoz wrote:
Hi Roger,

Do you need to use a double-checked locking idiom in getEchoStub?
Probably not, I'm  just practicing the idiom.
We are unlikely to move to concurrent test execution in testng (when it 
supports it).
I cannot recall the life-cycle of per test execution, but i suspect you might 
be able to turn the static field and method getEchoStub into a non-static field 
and just make the method synchronized, but you might ned to annotate the 
shutdown with @AfterClass instead.
That would work too.

What's the rule for choosing synchronized vs volatile?  I've gotten different 
recommendations in different cases.
What's Occam's razor here?
Double-checked locking requires both :-), so you can safely publish the 
singleton. It’s generally used when performance is a concern, otherwise i would 
go for the simpler solution which is more likely to be correct and easier to 
understand :-)


Actually, perhaps even better initiate the ORB and create the stub in a 
@BeforeClass method and clean up in a @AfterClass method?
that would work, but it is only used in one of the tests.  So just trying to 
keep the usage localized.

Ah, yes, i see.

Paul.


Reply via email to