Results 1 to 3 of 3
  1. #1
    waqar100 is offline Member
    Join Date
    May 2010
    Posts
    28
    Rep Power
    0

    Default transient vs volatile

    I want to know WHY the volatile and final keywords are not used on the same variable?

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    What does the JLS say about those two modifiers, and then you tell us, what you think the reason might be.

    IMO it is extremely obvious why they can't (or at least why it makes absolutely no sense to even attempt to do so) be used on the same variable.

  3. #3
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Your title is asking about transient vs volatile while your question is asking about volatile and final keywords. You may want to cross check your posts more carefully before posting them.

    volatile says the variable can be changed from multiple threads (no thread local caching) while final says the variable's value cannot be changed. You should now see that it doesn't make sense to use both on a variable.

Similar Threads

  1. Transient & Local
    By Supamagier in forum Advanced Java
    Replies: 5
    Last Post: 04-28-2009, 03:35 AM
  2. Transient & Volatile
    By Deepa in forum New To Java
    Replies: 2
    Last Post: 12-05-2008, 10:30 AM
  3. Transient vraible
    By serjant in forum Advanced Java
    Replies: 9
    Last Post: 11-10-2008, 03:13 PM
  4. Demonstration of the transient keyword
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-17-2008, 12:09 AM
  5. transient keyword
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-11-2007, 11:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •