• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why is Throwable.initCause synchronized?  RSS feed

 
Mogens Nidding
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a technical explanation as to why Throwable.initCause is synchronized when Throwable.getCause and the constructor Throwable.Throwable(Throwable cause) aren't? I am considering the memory model for java 1.4.

I mean, what use is it that initCause is synchronized when getCause isn't? Even though one thread calls initCause, and the cause field is flushed to shared memory because of synchronization, there is no guarantee that another thread calling getCause will read anything meaningful.

Please tell me that I'm getting this right!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!