magazine resources subscribe about advertising

New Architect Daily
Commentary and updates on current events and technologies

CMP Media E-Book

Download your copy today.

Research
Search for reports and white papers from industry vendors and analysts.

This Week at NewArchitect.com Subscribe now to our free email newsletter and get notified when the site is updated with new articles







Day of Defeat Online Gaming

 New Architect > Archives > 1996 > 10 > Features  

Multithreaded Programming in Java

When Two Threads are Better Than One

By Ken Arnold and James Gosling

Many real-world software problems can best be solved by using multiple threads of control. For example, an interactive program that displays data graphically often needs to let users change display parameters in real time. Interactive programs often obtain their best dynamic behavior using threads.

Single-threaded systems usually provide an illusion of multiple threads, by either using interrupts or polling. Polling mixes display and user-input parts of an application, and the display code particularly must be written so it will poll often enough to respond to user input in fractions of a second. Display code must either ensure that display operations take minimal time, or interrupt its own operations to poll. The consequent mixing of two unrelated functional aspects of a program leads to complex and frequently unmaintainable code.

Such problems are more easily solved in a multithreaded system. One thread of control updates the display with current data, and another responds to user input. If user input is complexýfilling out a form, for exampleýdisplay code can run independently until it receives new data. In a polling model, either display updates would have to stop for complex input, or complicated handshaking would have to occur so that display updates could continue while the user typed data into the form. Such a model of sharing control within a process can be directly supported in a multithreaded system instead of being handcrafted for each new polling case.<>




  Day of Defeat Online Gaming

home | daily | current issue | archives | features | critical decisions | case studies | expert opinion | reviews | access | industry events | newsletter | research | careers | info centers | advertising | subscribe | subscriber service | editorial calendar | press | contacts


Copyright © 2006 CMP Media, LLC Read our privacy policy, your California privacy rights, terms of service.
SDMG Web sites: BYTE.com, C/C++ Users Journal, Developer Pipeline, Dr. Dobb's Journal, DotNetJunkies, MSDN Magazine, Sys Admin,
SD Expo, SD Magazine, SqlJunkies, The Perl Journal, Unixreview, Windows Developer Network, New Architect

web2