Concurrency is an idea in computer science in which multiple computations are being processed simultaneously. In Scratch, concurrency means that you (apparently) can run multiple blocks simultaneously. The current Scratch player does this by switching the execution between different execution threads. Thus, multiple Scratch block are never executed at the same time. Therefore, in this case Scratch does not meet the true definition of concurrency, though it does manage ot mimic concurrency in its execution.

Benefits of Concurrency

Concurrency is beneficial for multiple reasons:

  • Concurrency can allow your project to continue running through intensive processes.
  • Concurrency can help speed up your project. This can also be done through the use of a Single Frame.
  • Concurrency allows you to have many things updating simultaneously.

Downfalls of Concurrency

While concurrency has many benefits and is used in many projects, it can also have many issues:

  • Concurrent modification, or 2 processes attempting to modify something simultaneously can cause unexpected results, such as this code:
when green flag clicked
broadcast [concurrent script v]
when I receive [concurrent script v]
set [foo v] to (1)
when I receive [concurrent script v]
set [foo v] to (3)
  • Concurrency can make controlling code flow quite difficult.

Concurrency in other Programming Languages

Some other programming languages, such as Lua, have concurrency support, with coroutines. A full list of languages that support concurrency can be found here.

Examples

Concurrency has many uses in Scratch:

  • Performing complex mathematical functions.
  • Rendering graphics
  • Moving multiple sprites simultaneously

External Links