Question 1
Which of the following best describes multithreading?
Running multiple processes on different machines
Running multiple threads within the same process concurrently
Running one thread after another in sequence
Running multiple programs at the same time
Question 2
Which C++ header file is required to use std::thread?
Â
Question 3
What will be the output of this code?
#include
#include
using namespace std;
void task() {
cout << "Hello from thread";
}
int main() {
thread t(task);
t.join();
}
No Output
Compilation Error
Hello from Thread
Runtime Error
Question 4
Why is thread synchronization necessary?
To make threads run faster
To avoid thread creation overhead
To prevent race conditions when accessing shared resources
To make all threads execute in sequence
Question 5
Which of the following is used in C++ for thread synchronization?
std::thread_guard
std::condition_variable only
 std::sync
std::mutex
Question 6
What happens if you call t.join() twice on the same std::thread object?
The thread restarts
 It is ignored
The program terminates without error
The program throws std::system_error
There are 6 questions to complete.