Ehsan Rahman

Ranch Hand
+ Follow
since Feb 16, 2009
Ehsan likes ...
Netbeans IDE VI Editor Chrome
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ehsan Rahman

Howdy All,

I passed officially on Sep 15th 2011. Unfortunately there was no marking information provided.

I'd like to thank the people: Roel De Nijs, Roberto Perillo and last but not least Andrew Monkhouse & Terry Camerlengo for the same reasons listed by Youcef Saidani.

The assignment was on 'Bodgitt & Scarper'. I didn't really deviate from any of the variety of approaches except perhaps for one aspect: I didn't use a value object. I decided a Map<String,String> object was more flexible in the future when passing records by specifying the field name and field value. Granted, there is the field name being passed on every message, but I've noticed this pattern in industry and decided to apply it.

I found to be a handy source code repository.

I've been able to apply my learning in industry and hope to continue applying it in the future.

Best Regards,
8 years ago
Hi Roel, thank you. I'm just being pedantic, that's all.

I think even using notifyAll(), a thread waiting on another record, as it wakes up and before it goes back to a waiting state will consume some CPU cycle as Oricio wrote.



Hi Everyone,

After coding up the locking section of the Data.class using synchronized methods and wait()/notify() calls for handling threads which are tying to lock on records already locked by other threads; I realized that technically the notify() call can wake up a thread wanting to lock on a different record. Better explained here

Oricio Ocle wrote:Ok think about that:

If the specified record is already locked by a different
client, the current thread gives up the CPU and consumes no CPU cycles until the record is unlocked.

.... But it's record has not been unlocked ...


So, I've now used ReentrantLocks similar to what Simon suggests here:

Simon Cockayne wrote:Hi Liviu,

Have a HashMap recordLocks: mapping key is wrapped a recNo. Mapping value is a RecordLock object.

A RecordLock class extends ReentrantLock and has a reference to the recordLock owner and a reference to a unique condition.

Ergo, any thread that wants to wait on the recordlock (so it can update the owner informaiton) can call theCondition.await().

And any thread that has finished with a recordLock (having unlocked it say) can call theCondition.signal().

This works fine but I'm struggling with removing the entries from the Map<RecNo, RecordLock>, where RecordLock just contains a ReentrantLock with a concurrent.locks.Condition to group the specific threads that wish to be woken up as the unlock of a specific record occurs to meat the criteria "the current thread gives up the CPU and consumes no CPU cycles until the record is unlocked."

I've been looking at WeakHashMaps and the ReentrantLock methods such as getHoldCount() or hasQueuedThreads() but it just seems difficult to safely remove the entries (and ensure no othre thread is waiting/using the ReentrantLock object). Of course, I could just leave them in the Map<,> and explain it doesn't take up much memory at all. Or I wonder if someone is going to answer that the original wait()/notify() is good enough and that if one just writes about it in their choices.txt that's it's easier for a junior programmer perhaps Oracle might let you off or just deduct a few points at worst ...

Many Thanks
Great score! Well done!
10 years ago
Well done, congratulations. Very interesting to read your comments. Good luck with the future certifications!
Excellent, well done!
10 years ago

Harry Henriques wrote:Hi Fellow Bloggers,
You can retrieve all records, but how can you search for all records?

Hi Harry,

I was confused with this too. It depends what one interprets as "search".

Google define:search - the activity of looking thoroughly in order to find something or someone

Such definitions do not mandate a criteria, just to get technical about it.

So I interpreted that "search for all records" to mean "retrieve all records". I'll be writing this in my choices.txt.

Hope that helps.

Well it does seem that this extra feature isn't required: Link
Dear All,

For the client GUI what approaches are people considering for informing the user in the case of:
- a lengthy RMI response (e.g. connecting to a server that doesn't exist) ?
- a 1/2 second wait for a booking to be made ?

Choices to notify a user of a 'pending transaction':
- Implement a status bar to show the progress: This does the job but a status bar is not asked for in the requirements and I don't think one is expected.
- Do nothing: This may result in marks lost. E.g. you press "Book" and although the push button was quick, it can take a few seconds before the update occurs. Also, if there is an RMI connection loss, it might take about 15 seconds before a warning appears of a connection loss. And when trying with Ubuntu, due to a Linux issue there has been an indefinite wait. Surely a user would want to be aware of this?
- It may also be the case that a client should not have to wait 15 seconds for a response, and perhaps certain sun.rmi Properties could be changed (although this is not recommended in certain previous versions of Java).

Many Thanks,
Have you tried running it using a debbuger? Then you'll see the constructor chaining and method overriding in action.
Hi Mark,

If I understand you correctly, you're trying to set up a Window's connection between the two computers to share files? i.e. using the windows "Share Folders" feature?

If so, then one thing I did today is to navigate to the Properties settings of a network connection, then under the 'Generals' tab install all client, service and protocols available.

10 years ago
Fantastic score, and thanks for sharing your thoughts. Congratulations!
10 years ago

Daniel Breitner wrote:
Is finally called when the GUI receives a shutdown request?

Hi Daniel,

Quick test:

Outputs ....

So the shutdown sequence does not ensure the finally block gets executed. Does this help?

EDIT: Updated the code to call exit() from another thread.