• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

meaning of keywords static, transient, volatile

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Please tell me the clear distinction among the following keywords defined by java.
=>static
=>transient
=>volatile
Thanks
Maghvendra.
 
Ranch Hand
Posts: 412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
static: you can have static variables as well as methods. both static variables and methods belong to the class and not to any particular instance of that class.(i am actually retyping this, sheriff, please look into this. this portion was lost during my first edit.)
eg:-

you access them like,

transient: this keyword prevents Serialization when used with a variable. that is it prevents that particular field which has been declared as transient not to be saved to the disk.

------------------
Raghav.
[This message has been edited by Raghav Sam (edited June 20, 2001).]
[This message has been edited by Raghav Sam (edited June 20, 2001).]
 
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maghvendra,
volatile is a keyword used in threads. Basically java lets individual threads hold their own copy of varaibles while they are executing. For narmal variables used in threads the threads copy is checked against a master copy only when objects that have that variable are locked or unlocked and other key times. Using volatile tells the compiler to check the threads copy against the master copy everytime the thread accesses the variable.
That was a quick explaination, for more details go here: http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html#36930
hope that helps

Dave
 
Wink, wink, nudge, nudge, say no more, it's a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic