RE: Concurrency-interest Digest, Vol 9, Issue 13

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

RE: Concurrency-interest Digest, Vol 9, Issue 13

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



İnanç Gümüş
McCann Worldgroup Turkey
Yazılım ARGE, Lotus AdServer Yazılım
 
[hidden email]
0 212 317 56 78 (direk)

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of [hidden email]
Sent: Saturday, October 15, 2005 7:01 PM
To: [hidden email]
Subject: Concurrency-interest Digest, Vol 9, Issue 13

Send Concurrency-interest mailing list submissions to
        [hidden email]

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
        [hidden email]

You can reach the person managing the list at
        [hidden email]

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" <[hidden email]>
Subject: RE: [concurrency-interest] Mixing volatile and synchronized
        together...
To: "'Tim Peierls'" <[hidden email]>
Cc: [hidden email]
Message-ID: <[hidden email]>
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:[hidden email]]
Sent: Friday, October 14, 2005 11:38 AM
To: Ryan LeCompte
Cc: [hidden email]
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 <[hidden email]>
Subject: Re: [concurrency-interest] Mixing volatile and synchronized
        together...
To: Ryan LeCompte <[hidden email]>
Cc: [hidden email]
Message-ID: <[hidden email]>
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" <[hidden email]>
Subject: [concurrency-interest] About LinkedHashMap
To: <[hidden email]>
Message-ID:
        <[hidden email]>
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 <[hidden email]>
Subject: Re: [concurrency-interest] Concurrent Programming in Java
To: [hidden email]
Message-ID: <[hidden email]>
Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed

On Thu, 13 Oct 2005 23:33:40 -0500 Bob Lee <[hidden email]>
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 <[hidden email]>
Subject: Re: [concurrency-interest] Mixing volatile and
        synchronizedtogether...
To: Ryan LeCompte <[hidden email]>
Cc: [hidden email]
Message-ID: <[hidden email]>
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:[hidden email]]
>Sent: Friday, October 14, 2005 11:38 AM
>To: Ryan LeCompte
>Cc: [hidden email]
>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 <[hidden email]>
Subject: Re: [concurrency-interest] Concurrent Programming in Java
To: Craig Mattocks <[hidden email]>
Cc: [hidden email]
Message-ID: <[hidden email]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Craig Mattocks wrote:
> On Thu, 13 Oct 2005 23:33:40 -0500 Bob Lee <[hidden email]>  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
[hidden email]
http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest


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

_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest