Hey Android devs.

The thread annotations like `@UiThread` and `@WorkerThread` didn't always
act like I expected so I decided to investigate and ended up writing a blog
post [1] about when they work and when they don't.

*tldr; they don't follow the call stack* – an annotated method will only
display a warning if the methods inside of it are annotated. Additionally,
`Runnable` instances (and similar APIs) can not infer which thread they
were posted to and need to be explicitly marked.

If you're curious, more details are in the post, or you can just see some
examples on Github [2].
- Mike (:mcomella)

[1]: http://mcomella.xyz/blog/2016/thread-annotations.html
[2]:
https://github.com/mcomella/ThreadAnnotationsTest/tree/master/app/src/main/java/xyz/mcomella/threadannotationstest
_______________________________________________
mobile-firefox-dev mailing list
mobile-firefox-dev@mozilla.org
https://mail.mozilla.org/listinfo/mobile-firefox-dev

Reply via email to