Threads - CMSC 132 Object-Oriented Programming II Threads in Java Department of Computer Science University of Maryland College Park 1 Problem

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CMSC 132: Object-Oriented Programming II Threads in Java Department of Computer Science University of Maryland, College Park
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Problem Multiple tasks for computer Perform useful computation (editor, browser, game) How does computer do everything at once? Multitasking Multiprocessing
Background image of page 2
3 Multitasking (Time-Sharing) Approach Computer does some work on a task Computer then quickly switch to next task Tasks managed by operating system (scheduler) Computer seems to work on tasks concurrently Can improve performance by reducing waiting
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 Multitasking Can Aid Performance Single task Two tasks
Background image of page 4
5 Multiprocessing (Multithreading) Approach Multiple processing units ( multiprocessor ) Computer works on several tasks in parallel Performance can be improved 4096 processor Cray X1 32 processor Pentium Xeon Dual-core AMD Athlon X2 Beowulf computer cluster (Borg, 52- node cluster used by McGill University Image/Info from Wikipedia )
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 Perform Multiple Tasks Using… 1. Process Definition – executable program loaded in memory Has own address space Each process may execute a different program Communicate via operating system, files, network May contain multiple threads
Background image of page 6
7 Perform Multiple Tasks Using… 2. Thread Definition – sequentially executed stream of instructions Shares address space with other threads Has own execution context Program counter, call stack (local variables) Communicate via shared access to data Multiple threads in process execute same program Also known as “lightweight process”
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
8 Motivation for Multithreading 1. Captures logical structure of problem May have concurrent interacting components Can handle each component using separate thread Simplifies programming for problem Example Web Server uses threads to handle … Multiple simultaneous web browser requests
Background image of page 8
9 Motivation for Multithreading 2. Better utilize hardware resources When a thread is delayed, compute other threads Given extra hardware, compute threads in parallel Reduce overall execution time Example Multiple simultaneous web browser requests… Handled faster by multiple web servers
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/04/2011 for the course CMSC 132 taught by Professor Padua-perez during the Spring '08 term at Maryland.

Page1 / 32

Threads - CMSC 132 Object-Oriented Programming II Threads in Java Department of Computer Science University of Maryland College Park 1 Problem

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online