How to realize multi threads in phab?

I want to realize two threads in phab.I want to learn it from some examples.Could you please give some examples?

What I want to do is as follows:
I want to creat a interface(one thread) with customers,which customers can interact with the programme,and I also want to create another thread to interact with the database.
How can I realize it?