From: Boris Punk on 29 Jul 2010 22:58 I'm not sure about this one. The basic IDE hard drive hasn't got the capability to read from two disk locations at the same time has it? Modern SSD drives may have. This lock is stating that multiple reads are ok, but just one write at a time is ok: http://download.oracle.com/javase/6/docs/api/java/util/concurrent/locks/ReadWriteLock.html How can that be? Imagine Thread A calling seek on the disk, then Thread B calling seek. Thread A then reads from B's location surely?
From: Arne Vajhøj on 29 Jul 2010 23:00 On 29-07-2010 22:58, Boris Punk wrote: > I'm not sure about this one. The basic IDE hard drive hasn't got the > capability to read from two disk locations at the same time has it? Modern > SSD drives may have. > > This lock is stating that multiple reads are ok, but just one write at a > time is ok: > http://download.oracle.com/javase/6/docs/api/java/util/concurrent/locks/ReadWriteLock.html > > How can that be? Imagine Thread A calling seek on the disk, then Thread B > calling seek. Thread A then reads from B's location surely? The ReadWriteLock is not related to the actual disk IO - it only coordinates between two or more threads. Arne
From: Boris Punk on 30 Jul 2010 00:35 "Arne Vajh�j" <arne(a)vajhoej.dk> wrote in message news:4c52403f$0$283$14726298(a)news.sunsite.dk... > On 29-07-2010 22:58, Boris Punk wrote: >> I'm not sure about this one. The basic IDE hard drive hasn't got the >> capability to read from two disk locations at the same time has it? >> Modern >> SSD drives may have. >> >> This lock is stating that multiple reads are ok, but just one write at a >> time is ok: >> http://download.oracle.com/javase/6/docs/api/java/util/concurrent/locks/ReadWriteLock.html >> >> How can that be? Imagine Thread A calling seek on the disk, then Thread B >> calling seek. Thread A then reads from B's location surely? > > The ReadWriteLock is not related to the actual disk IO - it only > coordinates between two or more threads. > > Arne > Fair enough - I was just read somewhere someone tried using it for a disk IO
From: Knute Johnson on 30 Jul 2010 12:21 On 7/29/2010 9:35 PM, Boris Punk wrote: > "Arne Vajh�j"<arne(a)vajhoej.dk> wrote in message > news:4c52403f$0$283$14726298(a)news.sunsite.dk... >> On 29-07-2010 22:58, Boris Punk wrote: >>> I'm not sure about this one. The basic IDE hard drive hasn't got the >>> capability to read from two disk locations at the same time has it? >>> Modern >>> SSD drives may have. >>> >>> This lock is stating that multiple reads are ok, but just one write at a >>> time is ok: >>> http://download.oracle.com/javase/6/docs/api/java/util/concurrent/locks/ReadWriteLock.html >>> >>> How can that be? Imagine Thread A calling seek on the disk, then Thread B >>> calling seek. Thread A then reads from B's location surely? >> >> The ReadWriteLock is not related to the actual disk IO - it only >> coordinates between two or more threads. >> >> Arne >> > Fair enough - I was just read somewhere someone tried using it for a disk IO > That is a common usage for RWL. The reading threads can be blocked when a write is about to occur. The actual read/write to the disk is another matter altogether. Caching and other things can affect that as well. -- Knute Johnson email s/nospam/knute2010/
From: Daniel Pitts on 30 Jul 2010 12:54
On 7/30/2010 9:21 AM, Knute Johnson wrote: > On 7/29/2010 9:35 PM, Boris Punk wrote: >> "Arne Vajh�j"<arne(a)vajhoej.dk> wrote in message >> news:4c52403f$0$283$14726298(a)news.sunsite.dk... >>> On 29-07-2010 22:58, Boris Punk wrote: >>>> I'm not sure about this one. The basic IDE hard drive hasn't got the >>>> capability to read from two disk locations at the same time has it? >>>> Modern >>>> SSD drives may have. >>>> >>>> This lock is stating that multiple reads are ok, but just one write >>>> at a >>>> time is ok: >>>> http://download.oracle.com/javase/6/docs/api/java/util/concurrent/locks/ReadWriteLock.html >>>> >>>> >>>> How can that be? Imagine Thread A calling seek on the disk, then >>>> Thread B >>>> calling seek. Thread A then reads from B's location surely? >>> >>> The ReadWriteLock is not related to the actual disk IO - it only >>> coordinates between two or more threads. >>> >>> Arne >>> >> Fair enough - I was just read somewhere someone tried using it for a >> disk IO >> > > That is a common usage for RWL. The reading threads can be blocked when > a write is about to occur. The actual read/write to the disk is another > matter altogether. Caching and other things can affect that as well. Perhaps its a common usage for the general concept of read/write lock, but in Java, the ReadWriteLock wouldn't be useful, since it doesn't prevent external processes from accessing the file. One place that the Java ReadWriteLock is useful for a Many-Access, Few-Write data-structure (eg, configuration object which changes rarely, but is used in many places). -- Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/> |