threads

Threads.addCachedThread

Threads.addCachedThread(aFunction) : String

Adds to the cached thread pool aFunction to be executed. Returns an UUID associated with the thread. The aFunction will receive the corresponding UUID as the first parameter. Note: it calls initCachedThreadPool if it wasn't previously and it won't work if any of the other start* of init* methods has been used previously.

Threads.addFixedThread

Threads.addFixedThread(aFunction) : String

Adds to the fixed thread pool aFunction to be executed. Returns an UUID associated with the thread. The aFunction will receive the corresponding UUID as the first parameter. Note: it calls initFixedThreadPool if it wasn't previously and it won't work if any of the other start* of init* methods has been used previously.

Threads.addOpenAFShutdownHook

Threads.addOpenAFShutdownHook(aFunction)

Adds aFunction to try to execute whenever OpenAF is going to shutdown. The latest hook added will be the first to be executed until the first hook added.

Threads.addScheduleThread

Threads.addScheduleThread(aFunction, aDelay) : String

Adds to the scheduled thread pool aFunction to be executed within aDelay in ms. Returns an UUID associated with the thread. The aFunction will receive the corresponding UUID as the first parameter. Note: it calls initScheduledThreadPool if it wasn't previously and it won't work if any of the other start* or init* methods has been used previously.

Threads.addScheduleThreadAtFixedRate

Threads.addScheduleThreadAtFixedRate(aFunction, aRate) : String

Adds to the scheduled thread pool aFunction to be executed at a fixed aRate in ms. Returns an UUID associated with the thread. The aFunction will receive the corresponding UUID as the first parameter. Note: it calls initScheduledThreadPool if it wasn't previously and it won't work if any of the other start* or init* methods has been used previously.

Threads.addScheduleThreadWithFixedDelay

Threads.addScheduleThreadWithFixedDelay(aFunction, aDelay) : String

Adds to the scheduled thread pool aFunction to be executed at a fixed aDelay in ms. Returns an UUID associated with the thread. The aFunction will receive the corresponding UUID as the first parameter. Note: it calls initScheduledThreadPool if it wasn't previously and it won't work if any of the other start* or init* methods has been used previously.

Threads.addSingleThread

Threads.addSingleThread(aFunction) : String

Adds to the single thread pool aFunction to be executed. Returns an UUID associated with the thread. The aFunction will receive the corresponding UUID as the first parameter. Note: it calls initSingleThreadPool if it wasn't previously and it won't work if any of the other start* of init* methods has been used previously.

Threads.addThread

Threads.addThread(aFunction) : String

Add a thread to call aFunction as callback. Returns an UUID associated with the thread. The aFunction will receive the corresponding UUID as the first parameter.

Threads.getNumberOfCores

Threads.getNumberOfCores() : number

Returns the number of cores identified by Java.

Threads.initCachedThreadPool

Threads.initCachedThreadPool()

Uses a thread pool situable for cached threads. Note: it ignores any previous thread added using addThread; It won't work if any of the other start* or init* methods has been used.

Threads.initFixedThreadPool

Threads.initFixedThreadPool(numberOfThreads)

Uses a thread pool situable for fixed threads where you can specify the numberOfThreads to use (by default the number of cores). Note: it ignores any previous thread added using addThread; It won't work if any of the other start* or init* methods has been used.

Threads.initScheduledThreadPool

Threads.initScheduledThreadPool(numberOfThreads)

Uses a thread pool situable for scheduled threads where you can specify the numberOfThreads to use (by default the number of cores). Note: it ignores any previous thread added using addThread; It won't work if any of the other start* or init* methods has been used.

Threads.initSingleThreadPool

Threads.initSingleThreadPool(numberOfThreads)

Uses a thread pool situable for single threads where you can specify the numberOfThreads to use (by default the number of cores). Note: it ignores any previous thread added using addThread; It won't work if any of the other start* or init* methods has been used.

Threads.start

Threads.start()

Start normally all threads added. Will wait for the end of execution of all threads. Note: it won't work if any of the other start* or init* methods has been used.

Threads.startAtFixedRate

Threads.startAtFixedRate(aTime)

Start all threads and restarts them at a fixed rate determined by aTime (in ms) independently of the time when the thread execution ends. Execution will stop upon Threads.stop.  Note: it won't work if any of the other start* or init* methods has been used.

Threads.startNoWait

Threads.startNoWait()

Start normally all threads added. Will not wait for the end of the execution of all threads. See Threads.waitForThreads for waiting for the execution of threads when needed or, in alternative, to Threads.start. Note: it won't work if any of the other start* or init* methods has been used.

Threads.startWithFixedRate

Threads.startWithFixedRate(aTime)

Start all threads and restarts them at a fixed rate determined by aTime (in ms) starting on the time when the thread execution ends. Execution will stop upon Threads.stop. Note: it won't work if any of the other start* or init* methods has been used.

Threads.stop

Threads.stop(shouldForce)

Stop all thread execution. If all threads need to be stopped immediately without waiting for the end of thread execution then used shouldForce = true.

Threads.sync

Threads.sync(aFunction)

Try to execute the aFunction in a synchronized method. Useful in parallel processing to safely access variables/resources shared between threads.

Threads.Threads

Threads.Threads() : Threads

Creates a new instance of a group of threads to manage.

Threads.waitForThreads

Threads.waitForThreads(aTimeout) : boolean

Waits for all threads to finish during aTimeout period (in ms). Returns true if all threads stopped or false otherwise.