Better thread locking

P

Paul Tomblin

Does java have a "built-in" class to do thread locking like a database
does? I want to maintain data consistency, so if a reader is working, no
writer can start but other readers can, and if a writer is working no
readers or writers can start. Is there something like that in the class
library already? Or should I write my own?
 
P

Piotr Kobzda

Paul said:
Does java have a "built-in" class to do thread locking like a database
does? I want to maintain data consistency, so if a reader is working, no
writer can start but other readers can, and if a writer is working no
readers or writers can start. Is there something like that in the class
library already? Or should I write my own?

Look at java.util.concurrent.locks classes. In particular ReadWriteLock
may appear useful for you.


piotr
 
P

Paul Tomblin

In a previous article said:
Look at java.util.concurrent.locks classes. In particular ReadWriteLock
may appear useful for you.

Is that in Java 1.5? I can't find it in the 1.4.2 documentation. Darn,
that means I can't use it yet (we've got one more release with the 1.5 jvm
but not using 1.5 features before we're allowed to use 1.5 for real - it's
a long story why).

Thanks for pointing that out.
 
D

Daniel Dyer

Is that in Java 1.5? I can't find it in the 1.4.2 documentation. Darn,
that means I can't use it yet (we've got one more release with the 1.5
jvm
but not using 1.5 features before we're allowed to use 1.5 for real -
it's
a long story why).

Yes it is in 5.0 and not in 1.4.2. However, it is based on Doug Lea's
util.concurrent library
(http://g.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html),
which you should be able to download and use with 1.4.2.

This link (http://dcl.mathcs.emory.edu/util/backport-util-concurrent/)
might be useful too.

Dan.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,275
Messages
2,571,377
Members
48,070
Latest member
nick_tyson

Latest Threads

Top