• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

About solving a deadlock problem in the exam

 
Ranch Hand
Posts: 451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On Monkhouse's book, p 156. It says:


There are many solutions to prevent deadlocks, among them: ....

Ignore the problem. Seriously- is it a requirement of your assignment? Is there a possibility that attempting to handle this problem could result in you making a mistake....


If there is a deadlock when the program is execute, I don't think I can use exception handling to handle this problem.
When deadlock happens, the program hangs forever. If that is the case, I can only improve the code, but I cannot use try catch block to throw exceptions and let the rest of the program execute.
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What's your question/problem?
 
Helen Ma
Ranch Hand
Posts: 451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When deadlock happens in a program, the program hangs and it won't continue. The users need to terminate the program themselves.
Is there any way to use try catch block to handle deadlock, so that the program can continue?
(The Monkhouse book says it is still possible to handle deadlock. In the book, it always says that we can ignore this problem in the exam.)
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here you'll find more info about handling a deadlock.

But for the assignment you should simple prevent a deadlock situation and then you don't have to worry about solving one.

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi !

Do you think that if we have validated our application without any deadlock issue it is still advised to implement a detection mechanism (like timeout for locking a record) ?

Thanks
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't see what's the added value of adding extra code which will never be used. It only has drawbacks: increased complexity, more code to maintain, more code = more chance for bugs,... So, a deadlock detection mechanism is not needed at all!
 
Bartender
Posts: 1558
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Helen Ma,

IMHO, once deadlock happens in your code, it doesn't matter what you do or how you handle it - a MUST requirement is already broken (and you know what happens in that case )

A highly recommended option is to avoid deadlock at all costs. There is a really nice explanation given in Monkhouse book about how to achieve no-deadlock situation. Surprisingly, preventing deadlock is quite easy and desirable than detecting deadlock and then handling it (not to mention that you'll have to make sure that your deadlock-handling code itself is deadlock free )

I would suggest to go through approaches suggested by Monkhouse.

I hope it helps.
 
Helen Ma
Ranch Hand
Posts: 451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Anayonkar,
Yes. I agree that deadlock avoidance is easier to handle than handling the code that hangs forever.
I remember Monkhouse suggests a very straightforward suggestion: make a thin client and let the server handle the business logic like retrieve and reserve DVD. If the client loses connection, it won't hold any locks. In the exam, I am thinking of building GUI on the client side application, make a facade to let the client to talk to the server remotely. Once multiple client requests are sent to the server, the server will hanle the request.
If I am using RMI, I don't think I need to create threads on the server to handle multiple client requests. To my knowledge so far, RMI itself will handle multiple client requests (multiple clients can talk to a single server and the RMI framework will handle the multiple threadings underneath the hood.)
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic