This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Interface non-access modifiers

 
Andreas Sandberg
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Folks,

Since interfact instance (non-local) variables are public static and final, why can they not have the keywords volatile or transient applied? Perhaps it doesn't make sense to use the keyword transient as the instance variables already belong to the class and therefore any object or request to that variable must reconcile it's own copy from main memory so there is never a chance of a race type condition. Also, I know transient is to be used for specifying when an instance variable shouldn't be serialized, correct? So are static variables never serializable then? Thanks for the help!

-Andreas
 
agrah upadhyay
Ranch Hand
Posts: 579
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Folks,

Since interfact instance (non-local) variables are public static and final, why can they not have the keywords volatile or transient applied? Perhaps it doesn't make sense to use the keyword transient as the instance variables already belong to the class and therefore any object or request to that variable must reconcile it's own copy from main memory so there is never a chance of a race type condition. Also, I know transient is to be used for specifying when an instance variable shouldn't be serialized, correct? So are static variables never serializable then? Thanks for the help!

I Think You got answer of your first problem.If you are left with
why final and volatile can't come together then remember
that final variables can not be changed..........but volatile means its
value can be changed anytime.So final and volatile together are contradictory.Right?
 
Andreas Sandberg
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Doh! Thanks for pointing the obvious out to me. I thought too much about that question instead of steping back for a second. Guess I've studied for enough today. Thanks though!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic