views:

80

answers:

1

Android has Looper, and iPhone has Run Loops. It seems like Blackberry would have a similar backed in facility to queue and run threads.

Does anyone know if there is?

A: 

I'm not too familiar with Android yet, but some quick reading shows that what you're looking for is the invoke series:

  • Application.invokeLater - this allows you to add a Runnable to the event queue of the main thread, optionally at a scheduled delay /repeat interval
  • Application.invokeAndWait - add the Runnable to the event queue of the main thread and wait for it to complete execution.
  • Application.cancelInvokeLater- cancel a scheduled invokeLater request.

Reference: http://www.blackberry.com/developers/docs/4.1api/net/rim/device/api/system/Application.html#invokeLater%28java.lang.Runnable%29

And: http://www.blackberry.com/developers/docs/4.1api/net/rim/device/api/ui/UiApplication.html

Marc Paradise
Thanks for the response. While the invoke series is similar, it doesn't allow you to specify what thread the invocation is happening on. In the case of BB its on the UI thread. With Android you can create/specify your own looper seperate the UI thread. There's a good explanation of it here: http://mindtherobot.com/blog/159/android-guts-intro-to-loopers-and-handlers/
lukejduncan
True; but this is unfortunately the closest equivalent. There's not really a better answer to be had - it's definitely possible to roll your own, but there's no way to attach a message queue to an arbitrary thread.
Marc Paradise