Reading
Add Comment
Multitasking:
Type:
1.Process based Multitasking
2.Thread based Multitasking
Process based multitasking:
- Run two or more program at a time
- A program is the smallest unit of ....
Thread based multitasking:
- Run a single program in multiple threads at a time
- A thread is the smallest unit of ....
- Example, one thread is writing content on a file at the same time another thread is performing spelling check.
- Run a single program in multiple threads at a time
- A thread is the smallest unit of ....
- Example, one thread is writing content on a file at the same time another thread is performing spelling check.
Threading in java:
Thread is a program's path of execution in which processor execute code of program in different part at same time.
Multi threading extends the idea of multitasking into applications where you can subdivide specific operations within a single application into individual threads. Each of the threads can run in parallel. The OS divides processing time not only among different applications, but also among each thread within an application.
links
links
.
Runnable :
> it is interface to implement by the class that need thread execution.
>It remains the option to extend that class by other superclasses or you can say it is flexible way to use thread execution.
>Must handle the exception or must enclosed the thread operations in try-catch block..
extend thread: it is class of thread to extend by the class that need thread execution.
| implements Runnable | extends Thread | |
|---|---|---|
| Inheritance option | extends any java class | No |
| Reusability | Yes | No |
| Object Oriented Design | Good,allows composition | Bad |
| Loosely Coupled | Yes | No |
| Function Overhead | No | Yes |
Join();
This method is used when we want to give priority to a thread to complete and after its completion start the other threads or its a method waits for a thread to die.
Type:
- Damon Thread
- Non Dmon theread
Damon Thread:
Continue execution after ending of program
Non Daemon Thread:
Stop after program finihes
Thread properties:
runnable:The object whoes run() run in the thread. link
Thread properties:
runnable:The object whoes run() run in the thread. link
0 comments:
Post a Comment