| Reply | « Previous Thread | Next Thread » |
|
import appuifw, thread, e32, os
t1,t2=0,0 def a(): global t1 t1=os.getpid() while True: print "thanks" def b(): global t2 t2=os.getpid() while True: print "abc" def start(): thread.start_new_thread(a,()) thread.start_new_thread(b,()) def stop(): os.popen("kill -9 "+str(t1)) appuifw.app.menu=[(u"Start", start), (u"stop", stop)] app_lock = e32.Ao_lock() app_lock.wait() here is an example code which simply starts two thread a() and b() when you select start from the menu, and stop a() when you select stop from the menu. However, my problem is how can I kill thread a(). Functions like os.kill,os.popen etc are just not available in pys60. Any ideas? It doesn't seem to be a difficult problem but i just can't find the answer on the web. |
|
Quite easy.Just put a condition variable .Try something like this:
Code:
import appuifw, thread, e32, os
t1,t2=0,0
running_a = 1
running_b = 1
def a():
global t1, running_a
t1=os.getpid()
while running_a == 1:
print "thanks"
def b():
global t2, running_b
t2=os.getpid()
while running_b == 1:
print "abc"
def start():
thread.start_new_thread(a,())
thread.start_new_thread(b,())
def stop():
global running_a, running_b
running_a = 0 //exits the thread a
running_b = 0 //exits the thread b
appuifw.app.menu=[(u"Start", start),
(u"stop", stop)]
app_lock = e32.Ao_lock()
app_lock.wait()
Best Regards, SajiSoft "The purpose of software engineering is to control complexity, not to create it." --§ajid Ali Anjum-- http://sajisoft.wordpress.com/ |
|
Quote:
Thank you very much. |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| Emulator crash immediatly after launched, SDK of S60 3nd | loopfinder | Symbian Tools & SDKs | 20 | 2009-07-26 23:36 |
| exit() and _Exit() for multi thread Open C app | kcomex | Open C/C++ | 3 | 2009-04-20 15:40 |
| S60 5th Edition emulator startup problem | gopitek | General Symbian C++ | 1 | 2009-01-13 17:51 |
| Multi RPointerArray lots of problems | sirtomash | General Symbian C++ | 8 | 2008-12-10 08:33 |
| Multi Thread problem | Segev | General Symbian C++ | 4 | 2007-05-03 20:38 |