What are the advantages or usage of threads?

Threads support concurrent operations. For example,
-- Multiple requests by a client on a server can be handled as an individual client thread.
-- Long computations or high-latency disk and network operations can be handled in the background without disturbing foreground computations or screen updates.

Threads often result in simpler programs.
-- In sequential programming, updating multiple displays normally requires a big while-loop that performs small parts of each display update. Unfortunately, this loop basically simulates an operating system scheduler. In Java, each view can be assigned a thread to provide continuous updates.
-- Programs that need to respond to user-initiated events can set up service routines to handle the events without having to insert code in the main routine to look for these events.

Threads provide a high degree of control.
-- Imagine launching a complex computation that occasionally takes longer than is satisfactory. A "watchdog" thread can be activated that will "kill" the computation if it becomes costly, perhaps in favor of an alternate, approximate solution. Note that sequential programs must muddy the computation with termination code, whereas, a Java program can use thread control to non-intrusively supervise any operation.

Threaded applications exploit parallelism.
-- A computer with multiple CPUs can literally execute multiple threads on different functional units without having to simulating multi-tasking ("time sharing").
-- On some computers, one CPU handles the display while another handles computations or database accesses, thus, providing extremely fast user interface response times.

People who read this post also read :


Easy "water hack" burns 2 lbs OVERNIGHT

Well over 160 000 women and men are hacking their diet with a simple and SECRET "liquids hack" to drop 1-2lbs every night in their sleep.

It's very simple and it works with everybody.

This is how to do it yourself:

1) Grab a clear glass and fill it up with water half the way

2) Now follow this weight losing hack

so you'll be 1-2lbs thinner the next day!

Post a Comment


Twitter Delicious Facebook Digg Stumbleupon Favorites More