{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

Info icon This 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
Image of page 1

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

View Full Document Right Arrow Icon
2 Administrivia Groups are more or less set HW1 is out ACM ACM Programming Research
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?
Image of page 3

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

View Full Document Right 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
Image of page 4
5 Process control First-level solution: run multiple processes “&” in UNIX, “start” in Win32 OS’s, fork( ) Works surprisingly well – many tasks are discrete and can be run separately Problem How to share information between processes? Often overkill
Image of page 5

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

View Full Document Right 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
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
Image of page 7

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

View Full Document Right 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!
Image of page 8
9 Why is it not predictable?
Image of page 9

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern