added thread monitoring for pimain.py