Results 1 to 8 of 8

Thread: transient and volatile....

  1. #1
    Contributing Member
    Join Date
    Sep 2006
    Answers
    962

    transient and volatile....

    What is the use of transient and voatile keyword in java ? In which situation we used transient and volatile keywords ?

    I check it google search but i am not clear about their definitions..

    ---------------------
    suresh


  2. #2
    Expert Member
    Join Date
    Dec 2006
    Answers
    204

    Re: transient and volatile....

    volatile keyword is used for variables that are changed by multiple threads. it instructs the processor to fetch new copy every time. not the catched value.


  3. #3
    Expert Member
    Join Date
    Oct 2005
    Answers
    383

    Re: transient and volatile....

    volatile keyword tell the the compiler that the variable modified by "volatile" can be cahnged unexpectedly by other parts of ur program


    Transient:when a variable is declared as transient ,thenits value need not persist when the object is stored.


    bye

    :)
    NEVER SAY DIE.

  4. #4
    Contributing Member
    Join Date
    Sep 2006
    Answers
    962

    Re: transient and volatile....

    Thanks barbie and shenoy.....can you tell me where it is( or which type of projects) mainly used ?

    ----------------
    suresh


  5. #5
    Expert Member
    Join Date
    Oct 2005
    Answers
    383

    Re: transient and volatile....

    Variables may be marked transient to indicate that they are not part of the persistent state of an object.
    For eg
    If an instance of the class abc:

    class abc {
    int x, y;
    transient l,m;
    }

    were saved to persistent storage by a system service,then only fields x and y will be saved.The variables l,and m are not serialized.

    Volatile:Volatile is generally used for handling THREADS effectively,
    For example Specifying a variable as volatile tells
    the JVM that any threads using that variable are not allowed to cache(hide) that
    value at all. Making the Variable "Volatile " will ensure that the compiler
    will get the content of the variable every time it is used and not cache its
    content.
    bye

    :)
    NEVER SAY DIE.

  6. #6
    Junior Member
    Join Date
    Dec 2006
    Answers
    5

    Thumbs up Re: transient and volatile....

    Quote Originally Posted by psuresh1982 View Post
    What is the use of transient and voatile keyword in java ? In which situation we used transient and volatile keywords ?

    I check it google search but i am not clear about their definitions..

    ---------------------
    suresh
    hi suresh
    u wanna want to know about transient

    when we serialize any object its all data members are serialized except the data members declared as transient.... fine.
    now about volatile..

    volatile is a keyword that must be applied when declaring any variable that will reference a device register. Without the use of volatile, the compile-time optimizer can inadvertently delete important accesses. Neglecting to use volatile might result in bugs that are difficult to track down.


  7. #7
    Contributing Member
    Join Date
    Sep 2006
    Answers
    962

    Re: transient and volatile....

    Thanks for your valuable reply.....

    Nice to hear you....

    ---------------
    suresh


  8. #8
    Junior Member
    Join Date
    Apr 2007
    Answers
    1

    Smile Re: transient and volatile....

    Quote Originally Posted by psuresh1982 View Post
    What is the use of transient and voatile keyword in java ? In which situation we used transient and volatile keywords ?

    I check it google search but i am not clear about their definitions..

    ---------------------
    suresh
    transient key word is used with variable those will not be serialized if you are using serialization in your code.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact