Web Workers

Threads

In computer science, a thread of execution is the smallest sequence of programmed instructions

Wikipedia

public Runnable task = new Runnable() {
    @Override
    public void run() {
        System.out.println("I'm in a separate thread");
    }
};

public void onButtonClick() {
    task.run();  
};

Why Threads?

Parallel computing

Not blocking UI

Threads in JavaScript?

Node

In Browsers?

Welcome Web Workers

an API that allows Web application authors to spawn background workers running scripts in parallel to their main page

W3C

Demo

What's Next?

Shared Web Workers

Demo

Thanks!

Web Workers

By extrategy

Web Workers

  • 1,337