I think I'm missing something here. I'm used to sending data from javascript to java and back with calls to execute and back with the callbackContext methods.
But if at some points, lets say I have a running thread that needs to send data to the javascript at regular intervals, how should I do that then ? (This assumes that this task is running and has not been triggered by a javascript action, thus no callbackContext is available)
You can always execute javascript from java doing this:
Or you can init the plugin and keep the callback doing this
Added example provided by Sephy
If what you need is communication from server to client in asynchronous way than websockets are the solution for you. Exact implementation depends on which web server you use so you'd net to give more details but they all work same way more or less.