On 14 Pa??, 17:59, "A. Farber" <alexander.far...@gmail.com> wrote:
Hello,
On 14 Okt., 15:33, Rze??nik <marcin.rzezni...@gmail.com> wrote:
On 14 Pa??, 15:18, "A. Farber" <alexander.far...@gmail.com> wrote:
I'm programming an embedded device which
receives data over USB device and saves it to
a file.
Won't this:http://java.sun.com/javase/6/docs/api/java/util/concurrent/locks/Read...
suit you better? It is lightweight, lock-free implementation.
unfortunately I don't have ReadWriteLock at the device.
I've come up with a solution that I've listed below,
but it is missing something minor - reports an
IllegalMonitorStateException even though
I have put synchronized(this) around the _writeLock.notify();
You do not own monitor on which you notify. notify() must be called on
a monitor which you own, you've acquired this' monitor but try to
notify _writeLock's monitor.
You should consider making _head and _tail volatile, you might end up
reading stalled value from cache without memory barrier.
(ReadwriteLock states memory barrier)
Could you explain this?
Not really :-) I am not sure whether I can take this apart without
wreaking confusion. Try:
http://jeremymanson.blogspot.com/2008/11/what-volatile-means-in-java.html
Look up 'java memory model'.
(synchronized statement states memory barrier as well, so you probably
do not need to anyway)
By the way, have you seen Patricia's response? Seems to be elegant and
easy to implement.
the reply to it.
java.util.concurrent.