Multithreading Producer Consumer Assignment
Consider the producer/consumer problem using Message objects using a BlockingQueue.
Create a class called Message which contains a String attribute to hold a message.
Create a Runnable class called Producer that will create 100 messages (use a for loop). Have the Producer use the [login to view URL]() method to vary the time to produce a Message (hint: use the index of the for loop to determine milliseconds to sleep each time through the loop: first time through the loop sleep 0 milliseconds, second time sleep 1 milliseconds, etc.). The Producer will place the messages in a BlockingQueue for the consumer to pick them up. Have the producer send a message containing the String "Exit" to signal that it is done producing. Use appropriate output display announcing the production of each message.
Create a Runnable class called Consumer to consume the messages from the producer. Have it get each message from the BlockingQueue The consumer will know when it is done by checking to see if the message content is "Exit". Have the Consumer use the [login to view URL]() method to delay consuming of each message by 10 milliseconds. Use appropriate output display announcing the consuming of each message.
Create a test program to test your Producer and Consumer classes. The test program will create a BlockingQueue of size 10 for the producer and consumer to use (BlockingQueue is in the [login to view URL] package). Create and run a producer and consumer thread. What are the results? Increase the consumer sleep time to 100 miliseconds and rerun the test program. What difference did that make?
Note: Answer questions by putting the results in a file called Results.txt. Place the [login to view URL] file in the main project folder.
I am a professional java developer and i can help building this Multithreading class for you. Is this needed asap? I am online right now. Thanks in advance.
Sir, i can work with java android PHP MYSQL HTML5 wordpress jquery bootstrap. I can do your work and can communicate with ease. So if you give me an opportunity to work with you i will be thankful to you.