1

So my Android app has a couple of threads that I have sitting in a loop, using sleep to keep from running non-stop. I would love to be able to send a message in between threads, or notifications if that's a better term.

Is there something I can use like Windows messages? I'm even thinking can each thread have a button, that isn't displayed and that I could send a notification to?

Thanks

Daniel K
  • 195
  • 1
  • 1
  • 11
  • Possible duplicate of [What is the relationship between Looper, Handler and MessageQueue in Android?](http://stackoverflow.com/questions/12877944/what-is-the-relationship-between-looper-handler-and-messagequeue-in-android) – Mike M. Aug 20 '16 at 05:27
  • use `android.os.Handler` for `Message` sending between threads – pskink Aug 20 '16 at 06:50

3 Answers3

0

Today I think the recommended way today is to use a AsyncTask.

To get something akin to the PostMessage method in the .net world, you could use a Handler, like described here.

vidstige
  • 12,492
  • 9
  • 66
  • 110
-1

you can implement Looper and use them. These might help you. Looper.html also below sample inter thread communication

harshal
  • 592
  • 6
  • 25
-1

Thread notifier will help you for this.

please try with below link http://www.avajava.com/tutorials/lessons/how-do-i-use-the-wait-and-notify-methods.html

Amit
  • 409
  • 1
  • 5
  • 12