• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help with a sync block in java - servlet  RSS feed

 
Ray mann
Ranch Hand
Posts: 48
Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys i need a bit of help, I don't seem to know the solution to this question in my assignment i will post the code and question below i would greatly appreciate any assistance ...thanks in advanced!

Question:

Modify the program in Assign4 to synchronize access to the instance variable, balance. Save the program as SyncBank.java. Because balance is a double and not an object, it cannot be used as the monitor. Use synchronized methods or synchronized blocks of code as appropriate. Simultaneously test two threads as was done in Assign4. Because the threads can complete too quickly to determine if they are interfering with each other, delay the adding of a deposit by inserting the following code within the synchronized block or method:



My code attempt so far:

 
Tushar Goel
Ranch Hand
Posts: 934
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What problem you are facing?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!