Results 1 to 4 of 4
Thread: volatile and synchornized
- 07-18-2007, 04:54 AM #1
Senior Member
- Join Date
- Mar 2007
- Posts
- 134
- Rep Power
- 0
- 07-18-2007, 04:59 AM #2
Senior Member
- Join Date
- Mar 2007
- Posts
- 134
- Rep Power
- 0
Yes , I got a reason for making the two as different .
Look we have scenario like this say we have two threads
First thread need to set the variable for the next thread
Second thread comes & checks the variable & finds it's not set , it return without doing it's task
Only volatile can solve this problem
So the conclusion is volatile is not a replacement for synchronization and vice versa
- 12-11-2007, 11:39 AM #3
Member
- Join Date
- Dec 2007
- Posts
- 3
- Rep Power
- 0
its call cheep read n write approach.
- 04-23-2008, 08:38 PM #4
Similar Threads
-
Keyword : volatile
By peiceonly in forum Advanced JavaReplies: 14Last Post: 01-18-2011, 06:15 PM -
volatile variable
By Java Tip in forum Java TipReplies: 0Last Post: 12-11-2007, 10:26 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks