Starting with Griffon 0.9.2 there's also the possibility to define an specific thread execution policy for methods and properties via annotations

This feature is only available for Groovy code at the moment as it relies on the AST Transformation framework.

You must annotate a method or property with @griffon.transform.Threading and define a value of type griffon.transform.Threading.Policy (though the annotation uses Threading.Policy.OUTSIDE_UITHREAD by default). Annotated methods and properties must conform to these rules

Here's a trivial example

package sample

import griffon.transform.Threading

class Sample { @Threading void doStuff() { // executed outside of the UI thread }

@Threading(Threading.Policy.INSIDE_UITHREAD_SYNC) void moreStuff() { // executed synchronously inside the UI thread }

@Threading def work = { // executed outside of the UI thread }

@Threading(Threading.Policy.INSIDE_UITHREAD_SYNC) def update = { // executed synchronously inside the UI thread } }

It is worth noting that a @Threading annotation applied to a Controller's action/method will take precedence, this means you can force an specific threading policy on a Controller action other than the default one.

package sample

class SampleController { @Threading(Threading.Policy.INSIDE_UITHREAD_ASYNC) def popupDialog = { // build and show the dialog }

def equivalentPopupDialog = { execInsideUIAsync { // build and show the dialog } } }