Architecture refector

Add main thread to control the main loop.
Add sub thread to control the sub commander.