Threads Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What does CPU stand for?

A

Central Processing Unit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How many cores did CPUs originally have?

A

1 core

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is significant about the number of cores in a CPU?

A

The amount of cores matters for how many parallel operations can be performed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is meant by parallel operations in a CPU?

A

Parallel operations refer to multiple processes being executed simultaneously by different cores.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How are threads related to CPU cores?

A

Each core in a CPU can have multiple threads assigned to it, allowing multiple sequences of programmed instructions to be executed concurrently.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Where can you see how many threads are running on a CPU?

A

In the Task Manager in Windows.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does it mean when a thread ‘hangs’?

A

It stops or waits, often due to a blocking operation or an error.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is concurrent programming?

A

Concurrent programming is a programming paradigm where different parts of a program are executed out-of-order or in partial order, without affecting the final outcome.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What happens during core switching between threads?

A

Core switching between threads, also known as context switching, involves the CPU switching from one thread to another, allowing multiple threads to share the CPU’s resources.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is asynchronous programming?

A

Asynchronous programming allows the CPU to switch between threads when one thread is idle or waiting (e.g., during a timeout or sleep), improving efficiency and responsiveness.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a thread in the context of programming?

A

A thread is the smallest unit of processing that can be performed in an operating system, often part of a process.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How does JavaScript handle threading?

A

JavaScript uses an event-driven, non-blocking I/O model with a single-threaded event loop, utilising Web Workers for parallel execution.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are Web Workers in JavaScript?

A

Web Workers are a feature in JavaScript that allow you to run scripts in background threads, enabling parallel execution without interfering with the main execution thread.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the main advantage of using asynchronous programming in JavaScript?

A

The main advantage is that it allows the program to remain responsive by performing other operations while waiting for long-running tasks to complete.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is a common issue with multi-threading in programming?

A

A common issue with multi-threading is the potential for race conditions, where multiple threads access shared resources simultaneously, leading to unpredictable results.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is a deadlock in concurrent programming?

A

A deadlock is a situation in concurrent programming where two or more threads are unable to proceed because each is waiting for the other to release a resource.

17
Q

Is Python single-threaded or multi-threaded?

A

Python is technically capable of multi-threading, but due to the Global Interpreter Lock (GIL), it is often considered effectively single-threaded for CPU-bound tasks. Multi-threading in Python works well for I/O-bound tasks.

18
Q

Is Java single-threaded or multi-threaded?

A

Java is multi-threaded. It has built-in support for multi-threading, making it a good choice for concurrent programming.

19
Q

Is JavaScript single-threaded or multi-threaded?

A

JavaScript is single-threaded. It runs on a single thread, but it can handle asynchronous operations through its event loop, enabling non-blocking execution.

20
Q

Is C++ single-threaded or multi-threaded?

A

C++ is multi-threaded. It provides support for multi-threading through libraries like the C++ Standard Library’s <thread> and various other concurrency features.</thread>

21
Q

Is Ruby single-threaded or multi-threaded?

A

Ruby is primarily single-threaded due to the Global Interpreter Lock (GIL), similar to Python. However, JRuby (Ruby on the JVM) can support true multi-threading.

22
Q

Is Go single-threaded or multi-threaded?

A

Go (Golang) is multi-threaded. It has built-in support for concurrent programming with goroutines, which are lightweight threads managed by the Go runtime.

23
Q

Is C# single-threaded or multi-threaded?

A

C# is multi-threaded. It has extensive support for multi-threading and parallel programming through the .NET framework.

24
Q

Is Rust single-threaded or multi-threaded?

A

Rust is multi-threaded. It provides robust support for multi-threading with a strong emphasis on safety and concurrency, avoiding data races through its ownership system.