This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
I am having a little trouble with my buffer that uses Thread synchronization. What is meant to happen is that the InputManager inputs a String into the buffer. The buffer is then passed to LineToChar, where it takes the String from the buffer using the take() method and extracts the string into individual letters. These individual letters should then be passed to the OutputManager through another buffer, where the OutputManager outputs the individual letters onto the screen.
The problem is that it appears to be getting stuck in deadlock after the letter "e". Can you please offer suggestions on why it is doing this and point me in the right direction on how to solve this? My code is below:
You never start the Output Manager threads. In LineToChar for each input line you create a new OutputManager on the same bufferOut but never start it. So nothing consumes the lines from bufferOut. Creating a thread object doesn't start the thread. And you probably only need to call and start one OutputManager object, not create them every time.
Also, I think there an error in InputManager: to start a thread, use the method start(), do not call directly run(). Run() is just a method like any other, and if you call it directly, it will be executed in your existing thread. Start() on the other hand creates a new thread and then executes the run() method there. So the only special thing about run() is the name, in that start() knows about it.