[concurrency-interest] RE: Concurrency-interest Digest, Vol 9, Issue 13

Inanc Gumus Inanc.Gumus at mccann.com.tr
Mon Oct 17 03:37:43 EDT 2005


Dawid, what is 'multi-field state invariant' ?? 


 
İnanç Gümüş
McCann Worldgroup Turkey
Yazılım ARGE, Lotus AdServer Yazılım
 
inanc_gumus at mccann.com.tr
0 212 317 56 78 (direk)

-----Original Message-----
From: concurrency-interest-bounces at cs.oswego.edu [mailto:concurrency-interest-bounces at cs.oswego.edu] On Behalf Of concurrency-interest-request at cs.oswego.edu
Sent: Saturday, October 15, 2005 7:01 PM
To: concurrency-interest at altair.cs.oswego.edu
Subject: Concurrency-interest Digest, Vol 9, Issue 13

Send Concurrency-interest mailing list submissions to
	concurrency-interest at altair.cs.oswego.edu

To subscribe or unsubscribe via the World Wide Web, visit
	http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
or, via email, send a message with subject or body 'help' to
	concurrency-interest-request at altair.cs.oswego.edu

You can reach the person managing the list at
	concurrency-interest-owner at altair.cs.oswego.edu

When replying, please edit your Subject line so it is more specific than "Re: Contents of Concurrency-interest digest..."


Today's Topics:

   1. RE: Mixing volatile and synchronized	together... (Ryan LeCompte)
   2. Re: Mixing volatile and synchronized	together... (Tim Peierls)
   3. About LinkedHashMap (Hu, Jinsong)
   4. Re: Concurrent Programming in Java (Craig Mattocks)
   5. Re: Mixing volatile and synchronizedtogether... (Dawid Kurzyniec)
   6. Re: Concurrent Programming in Java (Tim Peierls)


----------------------------------------------------------------------

Message: 1
Date: Fri, 14 Oct 2005 12:56:06 -0400
From: "Ryan LeCompte" <ryan.lecompte at pangonetworks.com>
Subject: RE: [concurrency-interest] Mixing volatile and synchronized
	together...
To: "'Tim Peierls'" <tim at peierls.net>
Cc: concurrency-interest at altair.cs.oswego.edu
Message-ID: <PANGOSERVER2A1x1Gv500000b8c at pangonetworks.com>
Content-Type: text/plain;	charset="us-ascii"

Great. I just wanted to be clear on the behavior. So it's okay then to use a volatile variable in a synchronized method/block as well as an unsynchronized method/block in the same class?

Thanks,
Ryan

-----Original Message-----
From: Tim Peierls [mailto:tim at peierls.net]
Sent: Friday, October 14, 2005 11:38 AM
To: Ryan LeCompte
Cc: concurrency-interest at altair.cs.oswego.edu
Subject: Re: [concurrency-interest] Mixing volatile and synchronized together...

Ryan LeCompte wrote:
> I know that there really isn't a need to do this, but I was wondering 
> if In other words, there is no harm in using a volatile variable in a 
> synchronized method or block, right?

Right, no harm. Depending on the situation, one or the other might be superfluous, but there is nothing unsafe about accessing a volatile in a synchronized block or method.

--tim



------------------------------

Message: 2
Date: Fri, 14 Oct 2005 14:29:27 -0400
From: Tim Peierls <tim at peierls.net>
Subject: Re: [concurrency-interest] Mixing volatile and synchronized
	together...
To: Ryan LeCompte <ryan.lecompte at pangonetworks.com>
Cc: concurrency-interest at altair.cs.oswego.edu
Message-ID: <434FF907.4070703 at peierls.net>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Ryan LeCompte wrote:
> Great. I just wanted to be clear on the behavior. So it's okay then to 
> use a volatile variable in a synchronized method/block as well as an unsynchronized method/block in the same class?

Yes. It's worth reading Jeremy Manson's response carefully:

Jeremy Manson wrote:
> Volatiles can actually be used anywhere fields with no modifiers can 
> be used.  It would actually be semantically harmless to mark every 
> field in your program volatile, if you wanted (BAD IDEA).  The 
> program's results should be the same, for correctly written code.  The 
> reasons it is a bad idea are: it would decrease performance, it would damage readability, and it probably wouldn't buy you the guarantees that you think it would buy you.
> 
> Now, as regards your case: it should be said that if you are using 
> locking everywhere the volatile is accessed, then the volatile isn't 
> going to provide additional assurances.  For this pattern to be 
> useful, there would have to be another thread that accesses value without blocking.


--tim



------------------------------

Message: 3
Date: Fri, 14 Oct 2005 16:30:27 -0400
From: "Hu, Jinsong" <jhu at glog.com>
Subject: [concurrency-interest] About LinkedHashMap
To: <concurrency-interest at altair.cs.oswego.edu>
Message-ID:
	<2E6D4A21A5611B4A8F1AA4E22BE04431877CEB at PA-GLOGEX01.glog.com>
Content-Type: text/plain;	charset="us-ascii"

I know this is an off-topic question to post here, but I did struggling to find the right way to use this class, and I know there are lot of experts in this mail list. I would appreciate it very much on this if you could throw some lights. 

Suppose I have a DataBlock which contains a list of DataElement, and I have a HashMap which basically acts a hash index to quickly identify the DataElement according to a given key. Now, if I get the element and I want to find the next element very quickly, but it seems to me that current Collection API does not provide a quick solution to this, it appears that I have to link the DataElement by myself to achieve this.
LinkedHashMap seems a promising solution to this problem, but it does not provide a public method to get the entry, it only guarantees the order of insertion or access.

Any thought? 

Thanks
Jinsong






------------------------------

Message: 4
Date: Fri, 14 Oct 2005 21:33:54 -0400
From: Craig Mattocks <mattocks at mac.com>
Subject: Re: [concurrency-interest] Concurrent Programming in Java
To: concurrency-interest at altair.cs.oswego.edu
Message-ID: <2606274b4689ce11871b0a328693e6bf at mac.com>
Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed

On Thu, 13 Oct 2005 23:33:40 -0500 Bob Lee <crazybob at crazybob.org>
wrote:

http://www.amazon.com/exec/obidos/tg/detail/-/0321349601/
qid=1129264349/sr=8-1/ref=pd_bbs_1/002-7330121-3353651? 
v=glance&s=books&n=507846

Really not shipping until February 10, 2006?



------------------------------

Message: 5
Date: Sat, 15 Oct 2005 01:50:19 -0400
From: Dawid Kurzyniec <dawidk at mathcs.emory.edu>
Subject: Re: [concurrency-interest] Mixing volatile and
	synchronizedtogether...
To: Ryan LeCompte <ryan.lecompte at pangonetworks.com>
Cc: concurrency-interest at altair.cs.oswego.edu
Message-ID: <4350989B.7060207 at mathcs.emory.edu>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Ryan LeCompte wrote:

>Great. I just wanted to be clear on the behavior. So it's okay then to 
>use a volatile variable in a synchronized method/block as well as an 
>unsynchronized method/block in the same class?
>
>Thanks,
>Ryan
>
>-----Original Message-----
>From: Tim Peierls [mailto:tim at peierls.net]
>Sent: Friday, October 14, 2005 11:38 AM
>To: Ryan LeCompte
>Cc: concurrency-interest at altair.cs.oswego.edu
>Subject: Re: [concurrency-interest] Mixing volatile and synchronized 
>together...
>
>Ryan LeCompte wrote:
>  
>
>>I know that there really isn't a need to do this, but I was wondering 
>>if In other words, there is no harm in using a volatile variable in a 
>>synchronized method or block, right?
>>    
>>
Yes, but keep in mind that a volatile (unsynchronized) reader will be able to see any value set in the middle of a synchronized block by any writer, so it is only OK if the volatile does not participate in a multi-field state invariant, and if there are no intermittent illegal values set temporarily to the variable inside synchronized blocks. In other words, it must be OK for the reader to see any value that can be possibly assigned anytime, including in the middle of the synchronized block, by any writer.

Good example: emulating atomic variables in Java 1.4: all writer methods are synchronized, but get() is a volatile-read.

Regards,
Dawid



------------------------------

Message: 6
Date: Sat, 15 Oct 2005 08:10:29 -0400
From: Tim Peierls <tim at peierls.net>
Subject: Re: [concurrency-interest] Concurrent Programming in Java
To: Craig Mattocks <mattocks at mac.com>
Cc: concurrency-interest at altair.cs.oswego.edu
Message-ID: <4350F1B5.5010409 at peierls.net>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Craig Mattocks wrote:
> On Thu, 13 Oct 2005 23:33:40 -0500 Bob Lee <crazybob at crazybob.org>  wrote:
> 
> http://www.amazon.com/exec/obidos/tg/detail/-/0321349601/qid=112926434
> 9/sr=8-1/ref=pd_bbs_1/002-7330121-3353651?v=glance&s=books&n=507846
> 
> Really not shipping until February 10, 2006?


No idea how Amazon arrived at that date. Our target is December availability.

--tim



------------------------------

_______________________________________________
Concurrency-interest mailing list
Concurrency-interest at altair.cs.oswego.edu
http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest


End of Concurrency-interest Digest, Vol 9, Issue 13
***************************************************



More information about the Concurrency-interest mailing list