Results 1 to 1 of 1
  1. #1
    Java Tip's Avatar
    Java Tip is offline Moderator
    Join Date
    Nov 2007
    Posts
    1,694
    Blog Entries
    430
    Rep Power
    10

    Default volatile variable

    Sometimes you face a scenario where you want concurrent threads to access a variable asynchronously. In such conditions, we use volatile variables. JVM ensures that value of volatile variable remain consistent within each thread.

    Java Code:
    class VolatileExample {
        volatile int counter;
        . . .
    }
    Last edited by JavaBean; 12-11-2007 at 11:59 AM.

Similar Threads

  1. Keyword : volatile
    By peiceonly in forum Advanced Java
    Replies: 13
    Last Post: 11-17-2010, 01:47 PM
  2. volatile and synchornized
    By goldhouse in forum Threads and Synchronization
    Replies: 3
    Last Post: 04-23-2008, 09:38 PM
  3. getting the value of variable
    By Lehane_9 in forum New To Java
    Replies: 2
    Last Post: 03-05-2008, 02:42 AM
  4. Getting variable value from a variable name
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-16-2008, 10:26 PM
  5. Tomcat variable
    By baltimore in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 08-07-2007, 07:40 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
  •