• Post Reply Bookmark Topic Watch Topic
  • New Topic

Want code for Dining Philosoper  RSS feed

 
Atul Bhartia
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello and Thanks Everyone

Can Anyone have the correct and easy solution for the Dining Philosopher. I have seen their are many solutions to this problem and they too use Semaphor. Code is obscure and I dont know how to use Semaphor.
Is their any other way.Please help me out.
 
Stephan van Hulst
Saloon Keeper
Posts: 7987
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Smells like homework.

Synchronization is inherently tricky. If you don't use a semaphore, you're going to end up using other locks or monitors. Semaphore is actually pretty straightforward.

Write your solution, and when you're stuck on it, show us and maybe we can help.
 
Atul Bhartia
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A sort of homework , I was asked in one of the interview to code this program. I am afraid to solve this kind of problem.How to approach this kind of programs ?

One more question:

I was asked to read the excel sheet in one of the interview. If I have given Java Documentation, How to find the appropriate API to read the Excel Sheet, as i was first time doing operations on excel sheet and I was denied
to use google.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're out of luck with respect to reading spreadsheets when you're restricted to the standard Java API - it does not contain such an API. You need to resort to Apache POI or a similar library.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Atul Bhartia wrote: I am afraid to solve this kind of problem.How to approach this kind of programs ?

don't be afraid. This is what it's like being a coder. You're given a task that seems overwhelming. I cannot tell you how many times i've been given a problem and my first thoughts are "I have NO idea how to do this. I'm going to fail.".

Then...

I take a deep breath and turn off my computer. I get pencil and paper, and turn on my brain. That is the secret to being a good programmer - you don't start by writing code, but by THINKING about the problem. Break it down into smaller pieces. then break those down further. sketch out what the screen should look like. work through some examples, all on paper.

only when you have a good, solid understanding of the issues should you consider writing a single line of code.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!