Threads Flashcards
What does CPU stand for?
Central Processing Unit
How many cores did CPUs originally have?
1 core
What is significant about the number of cores in a CPU?
The amount of cores matters for how many parallel operations can be performed.
What is meant by parallel operations in a CPU?
Parallel operations refer to multiple processes being executed simultaneously by different cores.
How are threads related to CPU cores?
Each core in a CPU can have multiple threads assigned to it, allowing multiple sequences of programmed instructions to be executed concurrently.
Where can you see how many threads are running on a CPU?
In the Task Manager in Windows.
What does it mean when a thread ‘hangs’?
It stops or waits, often due to a blocking operation or an error.
What is concurrent programming?
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.
What happens during core switching between threads?
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.
What is asynchronous programming?
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.
What is a thread in the context of programming?
A thread is the smallest unit of processing that can be performed in an operating system, often part of a process.
How does JavaScript handle threading?
JavaScript uses an event-driven, non-blocking I/O model with a single-threaded event loop, utilising Web Workers for parallel execution.
What are Web Workers in JavaScript?
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.
What is the main advantage of using asynchronous programming in JavaScript?
The main advantage is that it allows the program to remain responsive by performing other operations while waiting for long-running tasks to complete.
What is a common issue with multi-threading in programming?
A common issue with multi-threading is the potential for race conditions, where multiple threads access shared resources simultaneously, leading to unpredictable results.