class_6 - Software Engineering 3156 24-Sep-01#6 Concurrency...

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

View Full Document Right Arrow Icon
Software Engineering 3156 24-Sep-01 #6: Concurrency and Project Phil Gross
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 Administrivia Groups are more or less set HW1 is out ACM ACM Programming Research
Background image of page 2
3 Concurrency Humans perform tasks in parallel Computers need to do so, too In reality, not with 1-CPU computers: “multitasking” simulates How do we do it? How do we deal with the problems?
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 First cut One of the modern operating system’s tasks is to support job or process control Allow multiple programs (“processes”) to run at the same time ps command on UNIX; CTRL-SHIFT-ESC on WinNT/2k/XP Protect one process from another Not always true: RTOS – to be discussed later
Background image of page 4
5 Process control First-level solution: run multiple processes Works surprisingly well – many tasks are discrete and can be run separately Problem How to share information between processes? Often overkill
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 Threads Essentially, lightweight processes Ability to run concurrent sets of code in one process Access to the same variables, methods: information sharing easy
Background image of page 6
7 Threads in Java Class must extend Thread or implement Runnable Implement run( ) method Start by using .start( ), not .run( ) Example Suhit covering multithreaded server in recitation this week: perfect example of why you want this Handler class executed in Thread: one controller, amny handlers
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 Life is easy…? But wait: Say both threads modify the same variable Who wins? We do not know This is very, very bad – if we want randomness, we use java.util.Random!
Background image of page 8
9 Why is it not predictable? You’re
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 06/09/2010 for the course COMS 3156 taught by Professor Philgross during the Fall '01 term at Columbia.

Page1 / 30

class_6 - Software Engineering 3156 24-Sep-01#6 Concurrency...

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