Multithreaded program contains two or more parts that can run concurrently and each part can handle a different task at the same time making optimal use of the available resources specially when your computer has multiple CPUs.
A process is an executing instance of an application. for example, when you double-click the Microsoft Word icon, you start a process that runs Word. A thread is a path of execution within a process. Also, a process can contain multiple threads. When you start Word, the operating system creates a process and begins executing the primary thread of that process. It’s important to note that a thread can do anything a process can do. But since a process can consist of multiple threads, a thread could be considered a ‘lightweight’ process. Thus, the essential difference between a thread and a process is the work that each one is used to accomplish. Threads are used for small tasks, whereas processes are used for more ‘heavyweight’ tasks – basically the execution of applications.
More topics covered:
- threading library
- urllib.request library
- urllib.request download from web using urlretrieve
- daemon thread
- thread.isAlive
- daemon thread
- thread.name
- Thread target, args = (x,)
- threading.currentThread()
- urllib.request.urlopen(url).info().get(‘content-length‘)
Links:
- Class code: thread introduction
- Class code: solution ex 1
- Class code: solution ex 2 – global
- Class code: solution ex 2 – oop
- Class code: thread with parameter
- Class code: download url using thread
- threading – tutorials point
- Python threading – python docs
- Python urllib.request – python docs
- Home Work!
- Lesson Summary Video!
