Java Project
Budget $250-750 USD
Task 1. Run the initial program as is to observe the race condition and explain how the race condition may occur. Draw a simple UML sequence diagram to support your explanation. Add your explanation and the sequence diagram to [login to view URL] (Links to an external site.)
You can force the race condition to be more apparent by uncommenting the [login to view URL]() statements in the Account class.
Task 2. Implement protection code to resolve the race condition issue. Your solution must allow the bank to transfer multiple funds between unrelated accounts, e.g. from account [2] to account [5] and from account [3] to account [7] at the same time. You may use either synchronized object locks or classes implementing the Lock interface to prevent two transferring threads from accessing the same global variables simultaneously.
In addition to testing the bank at the end of all the transfers, we also want to test it periodically. Uncomment the line in [login to view URL] that reads: if (shouldTest()) test();
Run the program again and you will notice now that the test method reports an error again. This is because while the test method is summing the amounts in each account in one thread, transfers are still taking place in other threads. This is the source of another race condition. In the next tasks we will fix this.
Task 3. Refactor the method of testing into a new separate thread.
Task 4. Provide code protection so that the newly-created testing thread and any other transfer threads are running exclusively.
Now we have protected the critical sections of the code by providing mutual exclusion between the testing thread and the transfer threads. But we want to run the test at regular intervals, so we need a solution to guarantee that the test runs at the right time.
Task 5. Implement a wait/signal solution for the testing thread and transfer threads, i.e. the testing thread starts with a signal to all transferring threads, waits for all the transferring threads to finish the current transfer, and then takes over the testing task while all the transferring threads are waiting until the test is done.
Task 6. The initial code does not allow an account to transfer out funds if the transferring amount is greater than the account balance. Implement a wait/notify solution to defer the transfer until the account balance becomes greater than the transferring amount (assume the account will receive the funds later).
Task 7. Deadlock condition may occur if one thread finishes all the funds transfers and exits. Implement a solution in which all threads stop transferring (the bank is closed) whenever one thread completes its transfers. This will solve the deadlock issue.
20 freelancers are bidding on average $500 for this job
Hi, I am an expert developer on C, C++, Java, Python and MYSQL. More than a decade I was working for an American software company afterwards I started working as a consultant. Several data structure algorithms implemen More
Hi there, I am java developer with 7+ years of experience in web and desktop app and game development. I have strong expertise in oop, data structures, statistics, multi threading, networking, genetic algorithm impleme More
Hello, I've complete MS Software Engineering. I've 5-Year experience in Java development and algorithm implementation. My Core Expertise in Java - C++ - C - object-oriented - Data Structure - Swing - OpenGL - JavaFX. More
Hello JAVA EXPERT I have read your description and I am so interested in your project. You can see well experienced and skillful Java +15 years of experience in software development. Confident in your project and I can More
Hello, I am a software and Web Developer. I hava also lot of experience in Designing. I have some rules and regulations before start of project: 1. Provide 100% work within deadline. 2. Provide unlimited revisions un More
Hi, I can start work immediately. I have just read your project in detail and your project is very wonderful. I have rich experiences about your project and I can finish your project perfectly and on time. I am the bes More
How are you? I can implement your Java project. Thank you for checking my bid. I understand your needs and I think I can do it. If you hire me, I will do my best for you. I hope you would contact me and discuss details More
NOTE:I checked the attached file but not more deeply because may be i have some questions regarding to project, so its batter if you come to chat and we discuss more about it. I am a Java developer having 7 years of e More
---------------------------------------------------------------------------------------- Dear Client, Nice to meet you. I have read your description and I am so interested in your project. I am 5+yrs experience in Java More
Hi, Hope you are doing well. I have full experience about Java/JavaFX so that I can handle your project perfectly. I will be very happy to discuss about your project via chatting. Thank you.
hi I am really interested in your project I am new to Freelancer so I placed a bid for a low price But I have full experience of Java programming I could finish your project in high quality, in short timeline I could s More
Hello. I'm pretty happy to bid on this interesting project. I read your description carefully and I think that I am the developer you are looking for and are suitable for this task. I have rich experience in Java, Thre More
Hello. I hope you are doing well. I am a senior programmer and have 5+ years of Java. I have carried out many Java projects such as web scraping, jsp, search engine. So I can solve your problem in a very short time. Yo More