Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
But I didn't say that -- there is every reason to!Originally posted by Ramesh kumaar:
As u said if ur going to synchronize the method instred of a block then there is no need to implement wait() and notify().
That's not how it works. First of all, these methods are only called to set or release a lock. Their execution time is generally very brief, except when lock() blocks because a lock cannot immediately be acquired. But even then, concurrency is preserved because the wait() call releases the monitor lock held by the thread. This frees up the lock manager for other calls.Since u synchronize the entire method that allows only one request to be processed at time and all the remaining has to wait till the current request get completed, where i feel like concurrency is lost.
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
The lock() method in DataInterface has just one parameter. The lock() method in your lock manager must have two. So your Connection (or RemoteDataInterfaceImpl or whatever) might look something like the followingAnd the LockManager class might contain a method likeNote that I've secretly inverted your map; the locks map in this example maps record numbers to their owner instead of vice versa. There are two very good reasons for this.Originally posted by Sean Lee:
And I'm confused now, by your instruction, I create a new object for each remote client. But how can I pass the object to the lock method? it has only one parameter: recno.
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Cute. Clearly this is one of the areas where the interpretation of the requirements may differ; I interpreted as a kind of poor man's table lock and implemented both lock(-1) and unlock(-1). Your point of view would've saved me some workOriginally posted by Mark Spritzler:
Sean, lock(-1) can be assumed to be called only when the server wants to close.
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Hahaaa! I sense an opportunity to whip out my world-famous patented 3-tier architecture boilerplate diagram[tm].Originally posted by Sean Lee:
to use MVC pattern in this assignment, I wrote a Model interface and two classes to implement it: ModelLocalImpl and ModelRemoteImpl
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
This means that for a HashMap, a call to map.get(key) takes a more or less constant amount of time, regardless of how many elements there are in the map. In other words, its performance does not deteriorate when things get tough.Remember that a Map is very efficient (O(1) in the case of a HashMap) at finding the value for a given key.
This revolves around the question, what do you need to do to find out who the owner of a given lock is?In lock() and unlock(), you need to find out the owner for a given record lock. With the Map the wrong way around this is an O(n) operation. In my code, this is an efficient O(1) operation.
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |