简体   繁体   中英

How to force stop thread

I have PublishSubject for observing status change and also I have method with multiple steps, which I execute in another thread. How I can force stop this thread when subject received changes?

In spite of stopping a thread, you can stop emitting new elements and release resources of your PublishSubject. Inside your PublishSubject add a check for isDisposed and if it is true - stop emitting and call onCompleted. From your code dispose of your PublishSubject. I hope it'll help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM