Thank you all for your help. This site is full of lifesavers. Write a program th
ID: 3611396 • Letter: T
Question
Thank you all for your help. This site is full of lifesavers.Write a program that starts two detached threads that communicatevia a global string variable.
• The main thread must
• Set the common buffer to empty
• Start the communicating threads
• Exit
• The producer thread must run a loop that:
• Yields the CPU until the common buffer isempty
• Prompts the user for a string
• Reads it into the common buffer
until the user enters ^D (end of file). At that point theproducer can cause the entire
process to terminate.
• The consumer thread must run an infinite loop that:
• Yields the CPU until the common buffer isnon-empty
• Prints the buffer to the screen
• Sets the common buffer to empty