一个关于Python多线程的新手有关问题

一个关于Python多线程的新手问题
thread.start_new_thread()创建线程时,如果主线程main()执行完毕时,小线程还没有执行完毕的话,就会提示:
===================================
Unhandled exception in thread started by 
Error in sys.excepthook:

Original exception was:
===================================
那样的话,主线程我只能sleep()一个很长的时间,才能保证小线程能够执行完毕。

我想问的是,如何才能不用sleep()这种简单粗暴的方法去保证小线程的成功执行?

我是初学者,希望各位帮助一下,谢谢!

附测试代码:
from time import sleep,ctime
import thread

def loop0():
    print 'start loop 0 at:',ctime()
    sleep(4)
    print 'loop 0 done at:',ctime()
 
def loop1():
    print 'start loop 1 at:',ctime()
    sleep(2)
    print 'loop 1 done at:',ctime()
 
def main():
    print 'starting at:',ctime()
    thread.start_new_thread(loop0,())
    thread.start_new_thread(loop1,())
    sleep(10)
    print 'all DONE at:',ctime()
 
if __name__=='__main__':
    main()

------解决方案--------------------
试试高级模块threading先...
------解决方案--------------------
from threading import Thread
import time
class MyThread(Thread):
    def __init__(self):
        super(MyThread,self).__init__()
    def run(self):
        print 'hello,world'
        time.sleep(2.0)


t = MyThread()
t.start()
t.join()
------解决方案--------------------
join就是等待子线程执行完毕,至于之间的交互和信号发送要看下文档