PDA

View Full Version : How threads should implement in a desktop screen recorder ?


Chirag1729
Jul 28, 2016, 12:44 AM
Hi, I am interested in developing a desktop screen recorder.

What I have completed is :

1) I have a class which can capture desktop screen and provide you a screenshot.
2) I do have logic for converting the screenshots captured in a video.
3) A GUI which can control like start, stop, resume of screen capture.

I know that the next step is to have a thread which will capture the screenshots and the buttons from the GUI will control the screen capturing thread.

The question is : How can I control that screen capturing thread from the GUI class ?

What I have tried and didn't work :
I made a Recorder class extending Thread class. Now in the run method, an infinite loop is implemented which take screenshot every second.
GUI have buttons like start, stop, resume. An object of Recorder is created when user clicks start button. On Pause and resume button, wait() and notify() has been applied on the Recorder object.

But this is not working for me. It is giving "java.lang.IllegalMonitorStateException". I might have wrong implementation of the Threads here and might be the approach I am using is wrong. Please anybody will refer the right way to achieve it ?

Any help is appreciated.