in reply to how to write thread which was multithreaded port scan scripts for nmap
I am not sure, I understand your requirement clearly!
What I guess is,you have many domain names in psinfo table and want to scan those domain names with nmap command and you are currently scanning through each domain one by one with while loop. Now you want to start thread process for each domain name to scan with nmap and update back to the psinfo table ?
Please confirm is this your requirement? So that we can help you better!