Sunday, May 24, 2009

State Machine

Managing multiple-threaded application is quite tricky.. I spent a lot of time trying to do this and I ended up with an idea of a solution which is based on my previous experience designing hardware on an FPGA, using a state machine which is running on another thread and publishing the state to all the application.

The state machine controls all the thread activity inside the application and all the running thread must send a message to the state machine to change the state. Therefore the state machine acts as the manager of all the threads and by doing so we can control the activity of the threads.

I don't know the correct way of doing such thing, does anybody knows? however, this solution works for me..

Labels: , , ,