Threading and parallel execution

 We often use parallel execution. It is when :

  • Handling big data
  • Show records quickly when it requres conplex SELECT sqls many time

By using this function, you can write it simply and adjust the number of thread to run simultaneously.

Parallel execution support

 The Alinous-Core supports

  • parallel(){} block
  • local variable declare
  • Parallel.join() function
  • Parallel.joinAll() function

parallel block

 The  parallel block define the number of threads and script area to execute simultaneously.

parallel( [Number of threads] ){ [The code to execute by new threads]  }

local variable

 The space of variable is basically shared by parent and child threads. But there are variable to be private one for each children threads. Then use this declaration.

Parallel.join() function

 By calling the Parallel.join() function, parent(main) thread can wait for children threads finished.

If there are no join() call, the parent thread is executed without waitng for children threads

Example codes

I'll show you two cases. The difference between them is how to join the threads.

Single parallel block

This is a sample code using Parallel.join() function.

Multiple parallel blocks

This is a sample code using Parallel.joinAll() function.


Go to Top