[2039] in java-interest
Re: Object level concurrency control.
daemon@ATHENA.MIT.EDU (Jim.Graham@Eng.Sun.COM)
Fri Sep 22 07:22:01 1995
Date: Thu, 21 Sep 1995 11:50:54 -0700
To: java-interest@java.Eng.Sun.COM, lahurst@maths.tcd.ie
From: Jim.Graham@Eng.Sun.COM
> Seen as Java is both multithreaded and Object Oriented I was wondering
> if there was any object level concurrency control available or in the
> works. For example can one specify a set of methods as "serialised",
> meaning that only one of these methods can be executing at a time.
You can use the synchronized keyword to specify that a given method (or
even a given block of code inside a method) can be the only block running
in that object at any given time. That should do what you want.
Adding the the synchronized modifier to a method locks out all other
synchronized methods on that object for its duration, but the
"synchronized(obj) {}" form for synchronizing just a block of code lets
you explicitly control what you are synchronizing on for finer grain
control.
...jim
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com