Threading in GWT (client)

From what I understand, the entire client side of the GWT application is converted to Javascript when it is created, so I believe this question is related to both Javascript and the features that GWT offers.

I have several dozen processes that will need to be initiated in my GWT application, each process will continuously call the server. Does GWT support threading? Does the client side support GWT streams?

EDIT:

This link indicates:

No JavaScript knowledge required If you're just a user of the framework, which I am for the matter of discussion, you do not need to know JavaScript in order to write dynamic content, be it client-side such as rolling frames, docking panels or scheduled "multi-threading" tasks, or server-side calls using XMLHttpRequests (aka AJAX). 

or planned multi-threaded tasks, what does this mean?

+46
multithreading gwt
Apr 07 2018-10-10T00:
source share
4 answers

JavaScript does not support multithreading. However, GWT has a class for "simulating" threads, which is not real multithreaded, but in most cases does what you need: com.google.gwt.core.client.Scheduler.ScheduledCommand . This method is based on a timer class that executes the method after a specified time.

For example, when placing the following code in your own code, the scheduleDeferred method will return directly, and your code will continue after the command, and the execute() method will be executed using a timer:

 Scheduler.get().scheduleDeferred(new ScheduledCommand() { public void execute() { .. code here is executed using the timer technique. } }); 

You can create a repeating RepeatingCommand command that can be used to run a command more than once. Run it using Scheduler.get().scheduleIncremental() , which will execute the command until the execute method returns false . You can use this to separate tasks into subtasks to improve the behavior of "threads". Scheduler supports some additional methods for running a scheduled command in different ways. See JavaDoc for more details.

Edited and updated with the new GWT class instead of the deprecated DeferredCommand .

+34
Apr 7 '10 at 10:18
source share

There is work with web workers as part of HTML5, which is implemented in several browsers, but not at all (especially in Internet Explorer). You can use these functions where they are available, but what you need to do is look at the javascript programming model.

Javascript usually runs asynchronously. Requests are dismissed, and at some point their responses are accepted as an event. You can have a large number of pending requests at the same time. This will require a little redesign of your system.

+3
Apr 07 '10 at 9:33
source share

New way - use Scheduler

+1
Mar 30 2018-12-21T00:
source share

JavaScript does not support multithreading, so no matter what GWT does, multithreading should be done exclusively on the server side, since GWT can only use functions that are already available on the client side.

0
Apr 7 '10 at 8:10
source share



All Articles