ios - Stop and start NSThread in Swift -


i have thread runloop inside thread's main function working right. runloop inside while loop iterate if cancelled false.

public override func main() {      super.main()      var runloop: nsrunloop = nsrunloop.currentrunloop()     {         runloop.run()     } while(!self.cancelled)     nslog("thread stopped")     nsthread.exit() } 

when set cancel flag thread (through nstreah.cancel() method), thread appears end, thread stopped in console, when try start thread again getting attempt start thread again. how can restart thread without getting error?

you cannot restart thread. that's fundamental concept of multithreaded programming, thread runs once , when it's been stopped not restart. create new object instead.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -