What is multithreading? Give an example?



What is multithreading? Give an example?..

Answer / Nikesh Gupta

Multithreading is a method used in concurrent programming to allow the execution of multiple threads (lightweight processes) within the same program. Each thread can run independently without affecting other threads, allowing for more efficient use of system resources. Here's an example using Python's `threading` module: n```nimport threadingndef worker():n print('Thread is working...')n# Create a new threadnnew_thread = threading.Thread(target=worker)n# Start the new threadnnew_thread.start()nprint('Main thread is running...')n``

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Python Interview Questions

Explain about indexing and slicing operation in sequences?

1 Answers  


What is anagram in python?

1 Answers  


Explain the //, %, and ** operators in python?

1 Answers  


What are python dictionaries?

1 Answers  


How can files be deleted in python?

1 Answers  


What does == mean in python?

1 Answers  


Which is fastest implementation of python?

1 Answers  


Tell me what are different ways to create an empty numpy array in python?

1 Answers  


Why do list comprehensions write to the loop variable, but generators don’t?

1 Answers  


What is the comment tag in Python ?

1 Answers   Microsoft,


What is the different between range () and xrange () functions in python?

1 Answers  


What is difference between tuple and list?

1 Answers  


Categories