WorksheetsPython Threads
Total questions: 16
Worksheet time: 9mins
Which Python library runs a function as thread?
None
_threading
threading
thread
How does run() method is invoked?
By Thread.run()
By Thread.start()
By Thread.create()
None
How to terminate a blocking thread?
thread.stop() & thread.wait()
thread.stop()
thread.terminate()
None
Which method is used to identify a thread?
getThread()
None
getName()
get_ident()
What are the libraries in Python that support threads?
_threading
th
None
thread
How does global value mutation used for thread-safety?
via GIL (Global Interpreter Lock)
via Locking
via Mutex
None
What is the method to retrieve the list of all active threads?
getList()
getThreads()
enumerate()
threads()
Which thread method is used to wait until it terminates?
waitforthread()
join()
None
wait()
Multithreading is also called as ____________
Concurrency
Simultaneity
Crosscurrent
Recurrent
A single sequential flow of control within a program is ________
Process
Task
Thread
Structure
A method used to force one thread to wait for another thread to finish.
join()
connect()
combine()
concat()
How many CPUs (or cores) will the Python threading library take advantage of simultaneously?
Two
One
None
All of the available CPUs
What does the Thread.join() method do?
Adds the thread to a pool
Merges two threads into one
Waits for the thread to finish
Restricts access to a resource
Race conditions are …
Two threads incorrectly accessing a shared resource
Testing which thread completes first
Something you should add to your code
The weather on race day
Why is it a good idea to use a ThreadPoolExecutor as a context manager when you can?
It looks better
t passes exceptions back to the main program
It manages the start up of all threads and waits for them all to complete
It prevents the threads from having race conditions
True or False? Once you start a threading.Timer, you cannot stop it until it expires.
TRUE
FALSE
