0

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?

Daria
  • 347
  • 2
  • 5
  • 18
  • possible duplication of https://stackoverflow.com/questions/6186537/how-do-i-kill-an-android-thread-completely – Nik Dec 16 '19 at 08:06

1 Answers1

0

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.

Peter Staranchuk
  • 1,343
  • 3
  • 14
  • 29