Question: This assignment requires to be done in java and requires a class called MyPoint.java code for which is given below: public class MyPoint { private

This assignment requires to be done in java and requires a class called MyPoint.java code for which is given below:

public class MyPoint {

private int x;

private int y;

private boolean occupied = false;

public MyPoint()

{

x = 0;

y = 0;

}

public MyPoint(int x, int y)

{

this.x = x;

this.y = y;

}

public void setX(int x)

{

this.x = x;

}

public int getX()

{

return x;

}

public void setY(int y)

{

this.y = y;

}

public int getY()

{

return y;

}

public String toString() {

return "Point = (" + x + ", " + y + ")";

}

}

 This assignment requires to be done in java and requires a
class called MyPoint.java code for which is given below: public class MyPoint

Task To construct an example to demonstrate the producer/consumer problem and then adjust the example to solve the producer/consumer problem. Method Download MyPoint.java from the class website. Don't change the code. Part 1 In this part you will llustrate the producer/consumer problem by setting up two threads that use a shared buffer. Use Threads and/or Runnable objects. Do not use synchronized, wait, notifyAll or a boolean to control access to the shared buffer. Create classes as follows: BufferPoint-class to represent one MyPoint object with a get and set method Producer class-produces 10 MyPoint objects and writes them successively to a BufferPoint Consumer class consumes 10 MyPoint objects successively from a Buffer Point ProducerConsumerTest sets up a producer and consumer thread that both share the same BufferPoint When you run ProducerConsumerTest you should see output that prints every time the shared BufferPoint is written to or read from (see example on back) Part 2 Make copies of your files from Part 1 and make changes to correct the synchronization, a shared boolean and waitotify All Notes problem (see example on back). You should use For the threads only use the syntax we have used in class and in examples. Do not use any high-level classes or data structures. Turning in the Assignment You should upload two separate sets of 5 files for each part. Upload all java and class files to CourseWeb. If you want you can zip each set of 5 files into a folder before you upload. Do not turn in code printouts. Instead turn in the following in a folder printout of the output from Task 1 printout of the output from Task 2 description of what changes you made to the files from Task 1 in Task 2 completed Assignment Information Sheet

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!