import appuifw
import e32
import thread
def mine():
global running
print "new thread started"
while running:
print "thread running"
e32.ao_sleep(2)
print "thread stopped"
def startth():
global running
running=1
thread.start_new_thread(mine,())
def stopth():
global running
running=0
def cl():
appuifw.app.body.set(u"")
def about():
appuifw.note(u"programmed by shankar.")
def quith():
stopth()
print "bye"
lock.signal()
cl()
appuifw.app.title=u"thread_demo"
appuifw.app.exit_key_handler=quith
appuifw.app.menu=[(u"clear screen",cl),(u"Menu1",((u"About",about),(u"Quit",quith))),(u"thread",((u"start new",startth),(u"stop all",stopth)))]
lock=e32.Ao_lock()
lock.wait()

Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/bQtzwAtKr6w/13885