Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The problem with web workers is that they don't really fit the standard GWT/Java model - in my opinion they barely fit the standard JS model.</p> <p>Web workers work by passing data back and forth between what are essentially different JavaScript VMs. That data must be in the form of a string, and each worker has to load its JS separately. This means that no variables declared in one worker (or the main page) is accessible from another, unless it is passed as part of the string data, pushed back and forth between workers.</p> <p>So how does this work when you consider GWT/Java? From the Java perspective, this is not equivalent to multiple threads, but multiple JVMs! The different processes can only communicate by passing Strings (or more importantly, not Java objects) back and forth, and cannot share any other state. Even static variables might be different between the two virtual machines.</p> <p>From the link you posted, check out the source of <a href="http://code.google.com/searchframe#T04cSGC7sWI/trunk/elemental/src/elemental/js/html/JsWorker.java&amp;q=JsWorker%20package%3agoogle-web-toolkit.googlecode.com&amp;sq=&amp;ct=rc&amp;cd=1">JsWorker</a> - you can create an instance of this via <a href="http://code.google.com/searchframe#T04cSGC7sWI/trunk/elemental/src/elemental/js/html/JsWindow.java&amp;q=JsWorker%20package%3agoogle-web-toolkit.googlecode.com&amp;l=1119">JsWindow.newWorker</a> with the url of the JS script to start with, and JsWorker supports methods to listen for responses, and to send it messages to give it work to do. </p> <p>That script could be a GWT compiled object - but it would be a separate module and entrypoint than the original app, so that it only has the code it can reasonably run, and doesn't try to start drawing on the page when it loads. It would probably need to use a linker that would only load the JS, and wouldn't assume an iframe on the 'page'.</p> <p>The <a href="http://code.google.com/p/gwt-ns/wiki/WebWorker">GWT-NS</a> project has some web worker samples already, built using their own linker to construct js files to load to load in the worker, and some other convenience pieces as well.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload