Multi threading

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

Multi threading

#1

Postby Segi » Tue Mar 17, 2020 6:12 pm

Is it possible to execute a function thats defined in a shared script in a separate thread from the main thread in Verj IO ?
0 x

Steve
Moderator
Moderator
Posts: 414
Joined: Fri Sep 07, 2007 3:44 pm
Location: Sandy, UK
Contact:

Re: Multi threading

#2

Postby Steve » Wed Mar 18, 2020 11:05 am

Hi Segi,

You cannot run a shared script in a separate Thread, but can certainly define a separate thread to run in your script.

Something like this:

Code: Select all

var thread = new java.lang.Thread(
		function () { 
			for(var x =0; x<10; x++)
			{
				log("\nrunning : " + java.lang.Thread.currentThread().getName()); 
				java.lang.Thread.sleep(1000);
			}
		}
	);
	thread.start();
The example above shows how to spawn a new Thread. Note that you override the run() method with a defined function().

I hope this answers your question.

Kind regards

Steve
0 x

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

Re: Multi threading

#3

Postby Segi » Wed Mar 18, 2020 5:35 pm

Steve,

That's exactly what I am trying to do. I have a function in client callable functions that I want to run in a separate thread

When using $eb.executeFunctionAsynchronously doesn't that do the same kind of thing where it runs the function asynchronously by running in a separate thread ?
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

Re: Multi threading

#4

Postby Jon » Fri Mar 20, 2020 5:01 pm

When you use $eb.executeFunctionAsynchronously(), you're executing the function on the server and it will run in a separate thread anyway, you don't have to do anything to make this happen.

I think we may be at cross purposes here. Could you say a bit more about exactly what you're trying to do.
0 x


Who is online

Users browsing this forum: No registered users and 4 guests