-
Notifications
You must be signed in to change notification settings - Fork 6
threads
- Threads.Threads
- Threads.addCachedThread
- Threads.addOpenAFShutdownHook
- Threads.addScheduleThread
- Threads.addScheduleThreadAtFixedRate
- Threads.addScheduleThreadWithFixedDelay
- Threads.addThread
- Threads.getNumberOfCores
- Threads.initScheduledThreadPool
- Threads.start
- Threads.startAtFixedRate
- Threads.startNoWait
- Threads.startWithFixedRate
- Threads.stop
- Threads.sync
- Threads.waitForThreads
Threads.Threads() : Threads
Creates a new instance of a group of threads to manage.
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.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(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(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(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.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() : number
Returns the number of cores identified by Java.
Threads.initScheduledThreadPool(numberOfThreads)
Uses a thread pool situable for scheduled threads where you can specify the numberOfThreads to use (by defauly 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()
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(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()
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(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(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(aFunction)
Try to execute the aFunction in a synchronized method. Useful in parallel processing to safely access variables/resources shared between threads.
Threads.waitForThreads(aTimeout) : boolean
Waits for all threads to finish during aTimeout period (in ms). Returns true if all threads stopped or false otherwise.