Threads intercommunication API

There are scenarios when your template is parsing something in many threads and you need to keep track of some common data to avoid duplicating of results. There's API for that which allow broadcasting messages to all other threads and receiving those messages in your template.
For example, you have an array with some arbitrary data which needs to be updated in all the threads:

class Template implements OpenSubmitterTemplateProtocol {
    sharedData: number[] = []

When you'd like to update this sharedData in other threads, use broadcastMessageToThreads method:

async runTask(task: TemplateTask) {
    //... do something

    // broadcast shared data to other threads

    //... do something else

To receive the broadcast message, add method receiveBroadcastMessage to replace your sharedData:

receiveBroadcastMessage(data: any) {
    this.log('received shared data, size: '+data.length);

    //optionally checking for duplicates
    for (const number of data) {
        if (this.sharedData.indexOf(number) === -1) {

Full example is available in threads-comminication-example.ts template.