![]() | |
Teachers Assignments Other Pages | Project 1: Assigned: Fri Feb 16 2024 In this project, you will implement a blocking queue, which can handle multi-threaded calls to the add and remove methods. Important rules about what you're allowed to use/reference:
Part 0, 0 points: Create a new Java file, Part 1, 0 points: Start your MyBlockingQueue class and, in good Java practice, include a generic type for the type of objects that will be stored in your queue. In case you haven't done that before, you can do it like this: Part 2, 0 points: Add a constructor that takes a single int parameter. This will be the maximum number of elements that can be inside your MyBlockingQueue at any time. Think about what fields you want your class to have and do all the appropriate initialization in the constructor. (You'll likely have to come back here and change things as you continue through the project.) You can then create blocking queues like this: Part 3, 0 points: Add a method, Part 4, 10 points: Add a Part 5, 50 points: Add a method, Part 6, 7 points: Add a method, Part 7, 8 points: Add a method, Part 8, 0 points: At this point, you should be able to compile and run your queue with my code: BlockingQueueTester.java. Most of the project points are indicated there, though there isn't a perfect test for every part! If you put that in the same folder as your code, you can test your code like this: Part 9, 10 points: Make sure that your queue is FIFO (First-In, First-Out). Part 10, 30 points: Make sure that your remove method blocks appropriately: when there are no elements in the queue. Part 11, 30 points: Make sure that your add method blocks appropriately: when the queue is full. Part 12, 10 points: Make sure that your queue passes my stress tests. (There are some commented-out print statements you can comment-in as necessary while you're testing.) Part 13, 20 points: Make sure that there are no race conditions or possible deadlocks in your project. You may or may not see this during testing, so be very careful. I will look carefully at your code! Submitting your Project: Upload your MyBlockingQueue.java file to canvas. If you get it up before the deadline and send me a Slack message, I can run a test on my own computer. (There is no limit to the amount of times you can ask me to do this. The only barrier is how much time I actually have.) Make sure the names of all group members are in the code header. |