![]() |
|
![]() |
| LinkBack | Thread Tools | Display Modes |
| | #1 (permalink) |
| Senior Member Join Date: Aug 2006 Age: 29
Posts: 279
Thanks: 0
Thanked 9 Times in 9 Posts
Rep Power: 7 | VOLATILE MODIFIER QUESTION. Dear Friends, I want to know about "VOLATILE" Modifier in Java. What is VOLATILE MODIFIER? What is it's Use in Java? Where do we use it in Java? Can anybody explain it with programming example? ![]() |
| | |
| | #2 (permalink) |
| Moderator Join Date: Apr 2006 Location: India
Posts: 637
Thanks: 57
Thanked 91 Times in 70 Posts
Rep Power: 20 | Re: VOLATILE MODIFIER QUESTION. Hi radhika, I have never used Volatile modifier, and am not sure how does it work, Pls find the URL , you can get some info on this. go thru the site and let me know your questions, if u dont understand feel free to ask me, I 'll try to figure it out and will answer to ur questions http://java.sun.com/docs/books/jls/s...asses.doc.html Thank You |
| | |
| | #3 (permalink) |
| Member Join Date: Oct 2006
Posts: 66
Thanks: 2
Thanked 1 Time in 1 Post
Rep Power: 4 | Re: VOLATILE MODIFIER QUESTION. HI Radhika, In simple terms about volatile , u will declare any variable as volatile when there is in need of accessing by more than one thread , then volatile gives the fresh copy of that variable to each thread .. i.e say 2 threads A,B are using a non volatile variable called x=10,then first thread A is accessing the x var.after completion of thread A excution may be var x modified by A due to performing some operations so imagine now x= 20, in this case if thread B will access this var x then x value will be 20 , and ur requirement is for each thread u have to supply the default value of x as 10 ,so it's not possible by using any other modifier , now if u declare the var x as volatile then JVM will give a fresh copy of x to each thread excution. Thanks Last edited by harikotha; 03-10-07 at 04:15 PM.. |
| | |
![]() |
| Tags |
| modifier , question , volatile |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Interview questions you may be asked | yathish | HR Questions | 6 | 24-12-06 08:35 PM |
| Generic Question | toshivain | HR Questions | 3 | 24-12-06 02:07 PM |
| Simple (??) question: List test cases for File/Open feature in Microsoft Word | slinkanand | Testing Tools & QA | 2 | 01-11-06 07:18 PM |
| very good Question | Unregistered | Success Stories | 1 | 11-09-06 04:53 PM |
| want interview question & answer | pankajmurai | NETWORK ADMINISTRATION , HARDWARE & TROUBLESHOOTING | 1 | 20-07-06 11:32 AM |
| More Interview Questions Here... |