Chapter 9. Threading: Web workers and pthreads

This chapter covers

  • Using a web worker to fetch and compile a WebAssembly module
  • Instantiating a WebAssembly module on behalf of Emscripten’s JavaScript code
  • Creating a WebAssembly module that uses pthreads

In this chapter, you’re going to learn about different options for using threads in a browser with relation to WebAssembly modules.

Definition

A thread is a path of execution within a process, and a process can have multiple threads. A pthread, also known as a POSIX thread, is an API defined by the POSIX.1c standard for an execution module that’s independent of programming language (see https://en.wikipedia.org/wiki/POSIX_Threads).

By default, a web page’s UI and JavaScript ...

Get WebAssembly in Action now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.