SlideShare a Scribd company logo
Concurrent
Programming
01
Sachintha Gunasena MBCS
http://lk.linkedin.com/in/sachinthadtg
Learning Outcomes
Sachintha Gunasena MBCS
http://lk.linkedin.com/in/sachinthadtg
Learning Outcomes
• Demonstrate foundational computing knowledge of
concurrent systems, their performance opportunities and
how to implement them using:
• Java concurrent features and their semantics
• Java packages and APIs for concurrent programs
• Conventional synchronisation algorithms, data-
structures and APIs
• Wait-free and lock-free synchronisation controls.
Learning Outcomes Cont.d
• Apply knowledge of computing principles and technical
skills to parallelise tasks to improve their performance
and response characteristics by:
• Using abstraction and computational thinking
• Developing, implementing and testing the
effectiveness of alternate Java programs with
different levels of concurrency
• Critiquing the approach used to solve a problem by
evaluating its strengths and weaknesses
starting with the
basics…
Programming
• the process of writing computer programs.
• example
• Output
class First {
public static void main(String[] arguments) {
System.out.println("Let's do something using Java technology.");
}
}
OOP
• Object
• An object is a software bundle of related state and behavior. Software objects are often
used to model the real-world objects that you find in everyday life. This lesson explains how
state and behavior are represented within an object, introduces the concept of data
encapsulation, and explains the benefits of designing your software in this manner.
• Class
• A class is a blueprint or prototype from which objects are created. This section defines a
class that models the state and behavior of a real-world object. It intentionally focuses on
the basics, showing how even a simple class can cleanly model state and behavior.
• Inheritance
• Inheritance provides a powerful and natural mechanism for organizing and structuring your
software. This section explains how classes inherit state and behavior from their
superclasses, and explains how to derive one class from another using the simple syntax
provided by the Java programming language.
OOP Cont.d
• Encapsulation
• If a class disallows calling code from accessing internal object data and forces
access through methods only, this is a strong form of abstraction or information
hiding known as encapsulation
• Interface
• An interface is a contract between a class and the outside world. When a class
implements an interface, it promises to provide the behavior published by that
interface. This section defines a simple interface and explains the necessary
changes for any class that implements it.
• Package
• A package is a namespace for organizing classes and interfaces in a logical manner.
Placing your code into packages makes large software projects easier to manage.
This section explains why this is useful, and introduces you to the Application
Programming Interface (API) provided by the Java platform.
Concurrency
• a property of systems in which several computations are
executing simultaneously, and potentially interacting with
each other.
• The computations may be executing on multiple cores in the
same chip, preemptively time-shared threads on the same
processor, or executed on physically separated processors.
• A number of mathematical models have been developed for
general concurrent computation including Petri nets, process
calculi, the Parallel Random Access Machine model, the
Actor model and the Reo Coordination Language.
Concurrent Programming
• Concurrent object-oriented programming is a
programming paradigm which combines object-
oriented programming (OOP) together with
concurrency.
• While numerous programming languages, such as
Java, combine OOP with concurrency mechanisms
like threads, the phrase "concurrent object-oriented
programming" primarily refers to systems where
objects themselves are a concurrency primitive, such
as when objects are combined with the actor model.
Parallel Computing
• a form of computation in which many calculations
are carried out simultaneously, operating on the
principle that large problems can often be divided
into smaller ones, which are then solved at the
same time.
Concurrent vs Parallel
• you can have two threads (or processes) executing
concurrently on the same core through context switching.
• When the two threads (or processes) are executed on two
different cores (or processors), you have parallelism.
• in concurrency, parallelism is only "virtual", while the other
true parallelism.
• Therefore, every parallel program is concurrent, but the
converse is not necessarily true
Why Concurrency?
• Efficiency
• Time (load sharing)
• Cost (resource sharing)
• Availability
• Multiple access
• Convenience
• • Perform several tasks at once
• Modeling power
• Describing systems that are inherently parallel
Real World Example
• Computer systems are used for modeling objects in
the real world
• Object-oriented programming
• The world often includes parallel operation
• example:
• Limited number of seats on the same plane
• Several booking agents active at the same time
Terms
• Multiprocessing
• the use of more than one processing unit in a
system
• Parallel execution
• processes running at the same time
Terms Cont.d
• Interleaving
• several tasks active, only one running at a time
• Multitasking
• the OS runs interleaved executions
• Concurrency
• multiprocessing, multitasking, or any combination
Moore’s Law
Why it matters?
• The “end of Moore’s law as we knew it” has important implications on the
software construction process
• Computing is taking an irreversible step toward parallel architectures
• Hardware construction of ever faster sequential CPUs has hit physical
limits
• Clock speed no longer increases for every new processor generation
• Moore’s Law expresses itself as exponentially increasing number of
processing cores per chip
• If we want programs to run faster on the next processor generation, the
software must exploit more concurrency
Amdahl’s Law
Amdahl’s Law Cont.d
• We go from 1 processor to n. What gain may we
expect?
• Amdahl’s law severely limits our hopes!
• Define gain as:
• speed up = ( 1 / (( 1-p)+( p/n)) )
• where p = parallelizable %; n= number of processors
• Not everything can be parallelized!
Types of Parallel
Computation
• Flynn’s taxonomy: classification of computer
architectures
• Considers relationship of instruction streams to
data streams:
• SISD: No parallelism (uniprocessor)
• SIMD: Vector processor, GPU
• MIMD: Multiprocessing (predominant today)
MIMD Variants
• SPMD (Single Program Multiple Data):
• All processors run same program, but at
independent speeds; no lockstep as in SIMD
• MPMD (Multiple Program Multiple Data):
• Often manager/worker strategy: manager
distributes tasks, workers return result to
manager
Shared Memory Model
• All processors share a common memory
• Shared-memory communication
Memory
Processor
1
Processor
2
Processor
4
Processor
3
Distributed Memory Model
• Each processor has own local memory, inaccessible to
others
• Message passing communication
• Common for SPMD architecture
Process
or
Process
or
Process
or
Memory MemoryMemory
Message Passing
Client Server Model
• Specific case of the distributed model
• Examples: Database-centered systems, World-Wide
Web
Process
or
Process
or
Process
or
Memory Memory
Memory
SCOOP Mechanism
• Simple Concurrent Object-Oriented Programming
• Evolved through previous two decades; CACM (1993) and chap.
32 of Object-Oriented Software Construction, 2nd edition, 1997
• Prototype-implementation at ETH in 2007
• Implementation integrated within EiffelStudio in 2011 (by Eiffel
Software)
• Current reference: ETH PhD Thesis by Piotr Nienaltowski, 2008;
articles by Benjamin Morandi, Sebastian Nanz and Bertrand
Meyer, 2010-2011
SCOOP Preview: a
sequential program
transfer (source, target: ACCOUNT;
amount: INTEGER)
-- If possible, transfer amount from source to target.
do
if source.balance >= amount then
source.withdraw (amount)
target.deposit (amount)
end
end
Typical calls:
transfer (acc1, acc2, 100)
transfer (acc1, acc3, 100)
In a concurrent setting, using
SCOOP
transfer (source, target: separate ACCOUNT;
amount: INTEGER)
-- If possible, transfer amount from source to target.
do
if source.balance >= amount then
source.withdraw (amount)
target.deposit (amount)
end
end
Typical calls:
transfer (acc1, acc2, 100)
transfer (acc1, acc3, 100)
A better SCOOP version
transfer (source, target: separate ACCOUNT;
amount: INTEGER)
-- Transfer amount from source to target.
require
source.balance >= amount
do
source.withdraw (amount)
target.deposit (amount)
ensure
source.balance = old source.balance – amount
target.balance = old target.balance + amount
end
Dining Philosophers
• find out about it…
Programming: Then &
Now
Sequential Programming
• Used to be messy
• Still hard but key improvements:
• Structured programming
• Data abstraction & object technology
• Design by Contract
• Genericity, multiple inheritance
• Architectural techniques
Concurrent Programming
• Used to be messy
• Example: threading models in most popular
approaches
• Development level: sixties/seventies
• Only understandable through operational
reasoning
References
• http://www.javaworld.com/article/2078679/java-concurrency/java-concurrency-modern-
threading-for-not-quite-beginners.html
• https://books.google.mv/books?id=-
x1S4neCSOYC&pg=PA5&lpg=PA5&dq=what+is+using+concurrency+constructs&source=bl&ot
s=Dxdk47Ddy-
&sig=ZxzRD163royyROmEOF2lAtSZBz8&hl=en&sa=X&ved=0CEkQ6AEwBmoVChMIx-
rc1ZbYxwIVQQeOCh3LkguH#v=onepage&q=what%20is%20using%20concurrency%20constru
cts&f=false
• http://book.realworldhaskell.org/read/concurrent-and-multicore-programming.html
• https://books.google.mv/books?id=mHozgJ7ngq0C&pg=PA1&lpg=PA1&dq=what+is+using+con
currency+constructs&source=bl&ots=TOT_g-
IESw&sig=xSG7JzGquRD9NZmnbkt6tv6Vr2A&hl=en&sa=X&ved=0CFcQ6AEwCWoVChMIx-
rc1ZbYxwIVQQeOCh3LkguH#v=onepage&q=what%20is%20using%20concurrency%20constru
cts&f=false
• http://gee.cs.oswego.edu/dl/cpj/mechanics.html
• Read stack overflow / java documentation / etc
Next Up…
• Concurrent Programming…
Sachintha Gunasena MBCS
http://lk.linkedin.com/in/sachinthadtg
Thank you.
Sachintha Gunasena MBCS
http://lk.linkedin.com/in/sachinthadtg

More Related Content

What's hot (14)

Java New Evolution
Java New EvolutionJava New Evolution
Java New Evolution
Allan Huang
 
Concurrency Programming in Java - 06 - Thread Synchronization, Liveness, Guar...
Concurrency Programming in Java - 06 - Thread Synchronization, Liveness, Guar...Concurrency Programming in Java - 06 - Thread Synchronization, Liveness, Guar...
Concurrency Programming in Java - 06 - Thread Synchronization, Liveness, Guar...
Sachintha Gunasena
 
Multi-Threading
Multi-ThreadingMulti-Threading
Multi-Threading
Robert MacLean
 
Multithreading 101
Multithreading 101Multithreading 101
Multithreading 101
Tim Penhey
 
.NET: Thread Synchronization Constructs
.NET: Thread Synchronization Constructs.NET: Thread Synchronization Constructs
.NET: Thread Synchronization Constructs
Sasha Kravchuk
 
.NET Multithreading/Multitasking
.NET Multithreading/Multitasking.NET Multithreading/Multitasking
.NET Multithreading/Multitasking
Sasha Kravchuk
 
gcdtmp
gcdtmpgcdtmp
gcdtmp
TheFoolish Man
 
Threading in C#
Threading in C#Threading in C#
Threading in C#
Medhat Dawoud
 
multithreading
multithreadingmultithreading
multithreading
Rajkattamuri
 
Java Multithreading Using Executors Framework
Java Multithreading Using Executors FrameworkJava Multithreading Using Executors Framework
Java Multithreading Using Executors Framework
Arun Mehra
 
Concurrency with java
Concurrency with javaConcurrency with java
Concurrency with java
Hoang Nguyen
 
Java
JavaJava
Java
mdfkhan625
 
Java
JavaJava
Java
Khasim Cise
 
Multithreading
MultithreadingMultithreading
Multithreading
F K
 
Java New Evolution
Java New EvolutionJava New Evolution
Java New Evolution
Allan Huang
 
Concurrency Programming in Java - 06 - Thread Synchronization, Liveness, Guar...
Concurrency Programming in Java - 06 - Thread Synchronization, Liveness, Guar...Concurrency Programming in Java - 06 - Thread Synchronization, Liveness, Guar...
Concurrency Programming in Java - 06 - Thread Synchronization, Liveness, Guar...
Sachintha Gunasena
 
Multithreading 101
Multithreading 101Multithreading 101
Multithreading 101
Tim Penhey
 
.NET: Thread Synchronization Constructs
.NET: Thread Synchronization Constructs.NET: Thread Synchronization Constructs
.NET: Thread Synchronization Constructs
Sasha Kravchuk
 
.NET Multithreading/Multitasking
.NET Multithreading/Multitasking.NET Multithreading/Multitasking
.NET Multithreading/Multitasking
Sasha Kravchuk
 
Java Multithreading Using Executors Framework
Java Multithreading Using Executors FrameworkJava Multithreading Using Executors Framework
Java Multithreading Using Executors Framework
Arun Mehra
 
Concurrency with java
Concurrency with javaConcurrency with java
Concurrency with java
Hoang Nguyen
 
Multithreading
MultithreadingMultithreading
Multithreading
F K
 

Similar to Concurrency Programming in Java - 01 - Introduction to Concurrency Programming (20)

Share Unit 1- Basic concept of object-oriented-programming.ppt
Share Unit 1- Basic concept of object-oriented-programming.pptShare Unit 1- Basic concept of object-oriented-programming.ppt
Share Unit 1- Basic concept of object-oriented-programming.ppt
hannahrroselin95
 
Chapter no 1
Chapter no 1Chapter no 1
Chapter no 1
COMSATS Institute of Information Technology
 
Our Concurrent Past; Our Distributed Future
Our Concurrent Past; Our Distributed FutureOur Concurrent Past; Our Distributed Future
Our Concurrent Past; Our Distributed Future
C4Media
 
java oops and java very important for .pptx
java oops and java very important for .pptxjava oops and java very important for .pptx
java oops and java very important for .pptx
cherukuriyuvaraju9
 
java oops compilation object class inheritance.pptx
java oops compilation object class inheritance.pptxjava oops compilation object class inheritance.pptx
java oops compilation object class inheritance.pptx
CHERUKURIYUVARAJU209
 
1 intro
1 intro1 intro
1 intro
abha48
 
Object Oriented Methodology in Java (Lecture-1)
Object Oriented Methodology in Java (Lecture-1)Object Oriented Methodology in Java (Lecture-1)
Object Oriented Methodology in Java (Lecture-1)
Md. Mujahid Islam
 
Object Oriented Design and Programming Unit-01
Object Oriented Design and Programming  Unit-01Object Oriented Design and Programming  Unit-01
Object Oriented Design and Programming Unit-01
Sivakumar M
 
Unit 1- Basic concept of object-oriented-programming.ppt
Unit 1- Basic concept of object-oriented-programming.pptUnit 1- Basic concept of object-oriented-programming.ppt
Unit 1- Basic concept of object-oriented-programming.ppt
hannahroseline2
 
Object
ObjectObject
Object
guest94b187c
 
UNIT1- OBJECT ORIENTED PROGRAMMING IN JAVA- AIML IT-SPPU
UNIT1- OBJECT ORIENTED PROGRAMMING IN JAVA- AIML IT-SPPUUNIT1- OBJECT ORIENTED PROGRAMMING IN JAVA- AIML IT-SPPU
UNIT1- OBJECT ORIENTED PROGRAMMING IN JAVA- AIML IT-SPPU
ApurvaLaddha
 
Parallel architecture &programming
Parallel architecture &programmingParallel architecture &programming
Parallel architecture &programming
Ismail El Gayar
 
Different paradigms for problem solving.pptx
Different paradigms for problem solving.pptxDifferent paradigms for problem solving.pptx
Different paradigms for problem solving.pptx
iitjeesooraj
 
Computer_Programming_Part_II_Segment_01.pdf
Computer_Programming_Part_II_Segment_01.pdfComputer_Programming_Part_II_Segment_01.pdf
Computer_Programming_Part_II_Segment_01.pdf
et243047
 
Unit1 jaava
Unit1 jaavaUnit1 jaava
Unit1 jaava
mrecedu
 
Mathematical foundations of Multithreaded programming concepts in Java lang...
Mathematical foundations of Multithreaded   programming concepts in Java lang...Mathematical foundations of Multithreaded   programming concepts in Java lang...
Mathematical foundations of Multithreaded programming concepts in Java lang...
AM Publications,India
 
Introduction to Software - Coder Forge - John Mulhall
Introduction to Software - Coder Forge - John MulhallIntroduction to Software - Coder Forge - John Mulhall
Introduction to Software - Coder Forge - John Mulhall
John Mulhall
 
Concurrency Issues in Object-Oriented Modeling
Concurrency Issues in Object-Oriented ModelingConcurrency Issues in Object-Oriented Modeling
Concurrency Issues in Object-Oriented Modeling
IRJET Journal
 
Programming using C++ - slides.pptx
Programming using C++ - slides.pptxProgramming using C++ - slides.pptx
Programming using C++ - slides.pptx
HeadoftheDepartment
 
ProgrammingPrimerAndOOPS
ProgrammingPrimerAndOOPSProgrammingPrimerAndOOPS
ProgrammingPrimerAndOOPS
sunmitraeducation
 
Share Unit 1- Basic concept of object-oriented-programming.ppt
Share Unit 1- Basic concept of object-oriented-programming.pptShare Unit 1- Basic concept of object-oriented-programming.ppt
Share Unit 1- Basic concept of object-oriented-programming.ppt
hannahrroselin95
 
Our Concurrent Past; Our Distributed Future
Our Concurrent Past; Our Distributed FutureOur Concurrent Past; Our Distributed Future
Our Concurrent Past; Our Distributed Future
C4Media
 
java oops and java very important for .pptx
java oops and java very important for .pptxjava oops and java very important for .pptx
java oops and java very important for .pptx
cherukuriyuvaraju9
 
java oops compilation object class inheritance.pptx
java oops compilation object class inheritance.pptxjava oops compilation object class inheritance.pptx
java oops compilation object class inheritance.pptx
CHERUKURIYUVARAJU209
 
1 intro
1 intro1 intro
1 intro
abha48
 
Object Oriented Methodology in Java (Lecture-1)
Object Oriented Methodology in Java (Lecture-1)Object Oriented Methodology in Java (Lecture-1)
Object Oriented Methodology in Java (Lecture-1)
Md. Mujahid Islam
 
Object Oriented Design and Programming Unit-01
Object Oriented Design and Programming  Unit-01Object Oriented Design and Programming  Unit-01
Object Oriented Design and Programming Unit-01
Sivakumar M
 
Unit 1- Basic concept of object-oriented-programming.ppt
Unit 1- Basic concept of object-oriented-programming.pptUnit 1- Basic concept of object-oriented-programming.ppt
Unit 1- Basic concept of object-oriented-programming.ppt
hannahroseline2
 
UNIT1- OBJECT ORIENTED PROGRAMMING IN JAVA- AIML IT-SPPU
UNIT1- OBJECT ORIENTED PROGRAMMING IN JAVA- AIML IT-SPPUUNIT1- OBJECT ORIENTED PROGRAMMING IN JAVA- AIML IT-SPPU
UNIT1- OBJECT ORIENTED PROGRAMMING IN JAVA- AIML IT-SPPU
ApurvaLaddha
 
Parallel architecture &programming
Parallel architecture &programmingParallel architecture &programming
Parallel architecture &programming
Ismail El Gayar
 
Different paradigms for problem solving.pptx
Different paradigms for problem solving.pptxDifferent paradigms for problem solving.pptx
Different paradigms for problem solving.pptx
iitjeesooraj
 
Computer_Programming_Part_II_Segment_01.pdf
Computer_Programming_Part_II_Segment_01.pdfComputer_Programming_Part_II_Segment_01.pdf
Computer_Programming_Part_II_Segment_01.pdf
et243047
 
Unit1 jaava
Unit1 jaavaUnit1 jaava
Unit1 jaava
mrecedu
 
Mathematical foundations of Multithreaded programming concepts in Java lang...
Mathematical foundations of Multithreaded   programming concepts in Java lang...Mathematical foundations of Multithreaded   programming concepts in Java lang...
Mathematical foundations of Multithreaded programming concepts in Java lang...
AM Publications,India
 
Introduction to Software - Coder Forge - John Mulhall
Introduction to Software - Coder Forge - John MulhallIntroduction to Software - Coder Forge - John Mulhall
Introduction to Software - Coder Forge - John Mulhall
John Mulhall
 
Concurrency Issues in Object-Oriented Modeling
Concurrency Issues in Object-Oriented ModelingConcurrency Issues in Object-Oriented Modeling
Concurrency Issues in Object-Oriented Modeling
IRJET Journal
 
Programming using C++ - slides.pptx
Programming using C++ - slides.pptxProgramming using C++ - slides.pptx
Programming using C++ - slides.pptx
HeadoftheDepartment
 
Ad

More from Sachintha Gunasena (16)

Entrepreneurship and Commerce in IT - 14 - Web Marketing Communications
Entrepreneurship and Commerce in IT - 14 - Web Marketing CommunicationsEntrepreneurship and Commerce in IT - 14 - Web Marketing Communications
Entrepreneurship and Commerce in IT - 14 - Web Marketing Communications
Sachintha Gunasena
 
Entrepreneurship and Commerce in IT - 13 - The Internet Audience, consumer be...
Entrepreneurship and Commerce in IT - 13 - The Internet Audience, consumer be...Entrepreneurship and Commerce in IT - 13 - The Internet Audience, consumer be...
Entrepreneurship and Commerce in IT - 13 - The Internet Audience, consumer be...
Sachintha Gunasena
 
Entrepreneurship & Commerce in IT - 12 - Web Payments
Entrepreneurship & Commerce in IT - 12 - Web PaymentsEntrepreneurship & Commerce in IT - 12 - Web Payments
Entrepreneurship & Commerce in IT - 12 - Web Payments
Sachintha Gunasena
 
Concurrency Programming in Java - 03 - Essentials of Java Part 2
Concurrency Programming in Java - 03 - Essentials of Java Part 2Concurrency Programming in Java - 03 - Essentials of Java Part 2
Concurrency Programming in Java - 03 - Essentials of Java Part 2
Sachintha Gunasena
 
Concurrency Programming in Java - 02 - Essentials of Java Part 1
Concurrency Programming in Java - 02 - Essentials of Java Part 1Concurrency Programming in Java - 02 - Essentials of Java Part 1
Concurrency Programming in Java - 02 - Essentials of Java Part 1
Sachintha Gunasena
 
Entrepreneurship & Commerce in IT - 11 - Security & Encryption
Entrepreneurship & Commerce in IT - 11 - Security & EncryptionEntrepreneurship & Commerce in IT - 11 - Security & Encryption
Entrepreneurship & Commerce in IT - 11 - Security & Encryption
Sachintha Gunasena
 
Entrepreneurship & Commerce in IT - 08 - E-Commerce business models and concepts
Entrepreneurship & Commerce in IT - 08 - E-Commerce business models and conceptsEntrepreneurship & Commerce in IT - 08 - E-Commerce business models and concepts
Entrepreneurship & Commerce in IT - 08 - E-Commerce business models and concepts
Sachintha Gunasena
 
Entrepreneurship & Commerce in IT - 10 - The Internet today and How to build ...
Entrepreneurship & Commerce in IT - 10 - The Internet today and How to build ...Entrepreneurship & Commerce in IT - 10 - The Internet today and How to build ...
Entrepreneurship & Commerce in IT - 10 - The Internet today and How to build ...
Sachintha Gunasena
 
Entrepreneurship & Commerce in IT - 09 - The internet and the world wide web
Entrepreneurship & Commerce in IT - 09 - The internet and the world wide webEntrepreneurship & Commerce in IT - 09 - The internet and the world wide web
Entrepreneurship & Commerce in IT - 09 - The internet and the world wide web
Sachintha Gunasena
 
Entrepreneurship and Commerce in IT - 07 - Introduction to E-Commerce I - e-c...
Entrepreneurship and Commerce in IT - 07 - Introduction to E-Commerce I - e-c...Entrepreneurship and Commerce in IT - 07 - Introduction to E-Commerce I - e-c...
Entrepreneurship and Commerce in IT - 07 - Introduction to E-Commerce I - e-c...
Sachintha Gunasena
 
Entrepreneurship and Commerce in IT - 06 - Funding, Expanding, and Exit Strat...
Entrepreneurship and Commerce in IT - 06 - Funding, Expanding, and Exit Strat...Entrepreneurship and Commerce in IT - 06 - Funding, Expanding, and Exit Strat...
Entrepreneurship and Commerce in IT - 06 - Funding, Expanding, and Exit Strat...
Sachintha Gunasena
 
Entrepreneurship and Commerce in IT - 05 - Marketing, Technology and Marketin...
Entrepreneurship and Commerce in IT - 05 - Marketing, Technology and Marketin...Entrepreneurship and Commerce in IT - 05 - Marketing, Technology and Marketin...
Entrepreneurship and Commerce in IT - 05 - Marketing, Technology and Marketin...
Sachintha Gunasena
 
Entrepreneurship & Commerce in IT - 01 - Introduction in to Entrepreneurship,...
Entrepreneurship & Commerce in IT - 01 - Introduction in to Entrepreneurship,...Entrepreneurship & Commerce in IT - 01 - Introduction in to Entrepreneurship,...
Entrepreneurship & Commerce in IT - 01 - Introduction in to Entrepreneurship,...
Sachintha Gunasena
 
Entrepreneurship & Commerce in IT - 02 - Basic Concepts of Entrepreneurship, ...
Entrepreneurship & Commerce in IT - 02 - Basic Concepts of Entrepreneurship, ...Entrepreneurship & Commerce in IT - 02 - Basic Concepts of Entrepreneurship, ...
Entrepreneurship & Commerce in IT - 02 - Basic Concepts of Entrepreneurship, ...
Sachintha Gunasena
 
Entrepreneurship & Commerce in IT - 04 - Marketing Plan, Marketing 7 P's, STP...
Entrepreneurship & Commerce in IT - 04 - Marketing Plan, Marketing 7 P's, STP...Entrepreneurship & Commerce in IT - 04 - Marketing Plan, Marketing 7 P's, STP...
Entrepreneurship & Commerce in IT - 04 - Marketing Plan, Marketing 7 P's, STP...
Sachintha Gunasena
 
Entrepreneurship & Commerce in IT - 03 - Writing a Business Plan, Creating a ...
Entrepreneurship & Commerce in IT - 03 - Writing a Business Plan, Creating a ...Entrepreneurship & Commerce in IT - 03 - Writing a Business Plan, Creating a ...
Entrepreneurship & Commerce in IT - 03 - Writing a Business Plan, Creating a ...
Sachintha Gunasena
 
Entrepreneurship and Commerce in IT - 14 - Web Marketing Communications
Entrepreneurship and Commerce in IT - 14 - Web Marketing CommunicationsEntrepreneurship and Commerce in IT - 14 - Web Marketing Communications
Entrepreneurship and Commerce in IT - 14 - Web Marketing Communications
Sachintha Gunasena
 
Entrepreneurship and Commerce in IT - 13 - The Internet Audience, consumer be...
Entrepreneurship and Commerce in IT - 13 - The Internet Audience, consumer be...Entrepreneurship and Commerce in IT - 13 - The Internet Audience, consumer be...
Entrepreneurship and Commerce in IT - 13 - The Internet Audience, consumer be...
Sachintha Gunasena
 
Entrepreneurship & Commerce in IT - 12 - Web Payments
Entrepreneurship & Commerce in IT - 12 - Web PaymentsEntrepreneurship & Commerce in IT - 12 - Web Payments
Entrepreneurship & Commerce in IT - 12 - Web Payments
Sachintha Gunasena
 
Concurrency Programming in Java - 03 - Essentials of Java Part 2
Concurrency Programming in Java - 03 - Essentials of Java Part 2Concurrency Programming in Java - 03 - Essentials of Java Part 2
Concurrency Programming in Java - 03 - Essentials of Java Part 2
Sachintha Gunasena
 
Concurrency Programming in Java - 02 - Essentials of Java Part 1
Concurrency Programming in Java - 02 - Essentials of Java Part 1Concurrency Programming in Java - 02 - Essentials of Java Part 1
Concurrency Programming in Java - 02 - Essentials of Java Part 1
Sachintha Gunasena
 
Entrepreneurship & Commerce in IT - 11 - Security & Encryption
Entrepreneurship & Commerce in IT - 11 - Security & EncryptionEntrepreneurship & Commerce in IT - 11 - Security & Encryption
Entrepreneurship & Commerce in IT - 11 - Security & Encryption
Sachintha Gunasena
 
Entrepreneurship & Commerce in IT - 08 - E-Commerce business models and concepts
Entrepreneurship & Commerce in IT - 08 - E-Commerce business models and conceptsEntrepreneurship & Commerce in IT - 08 - E-Commerce business models and concepts
Entrepreneurship & Commerce in IT - 08 - E-Commerce business models and concepts
Sachintha Gunasena
 
Entrepreneurship & Commerce in IT - 10 - The Internet today and How to build ...
Entrepreneurship & Commerce in IT - 10 - The Internet today and How to build ...Entrepreneurship & Commerce in IT - 10 - The Internet today and How to build ...
Entrepreneurship & Commerce in IT - 10 - The Internet today and How to build ...
Sachintha Gunasena
 
Entrepreneurship & Commerce in IT - 09 - The internet and the world wide web
Entrepreneurship & Commerce in IT - 09 - The internet and the world wide webEntrepreneurship & Commerce in IT - 09 - The internet and the world wide web
Entrepreneurship & Commerce in IT - 09 - The internet and the world wide web
Sachintha Gunasena
 
Entrepreneurship and Commerce in IT - 07 - Introduction to E-Commerce I - e-c...
Entrepreneurship and Commerce in IT - 07 - Introduction to E-Commerce I - e-c...Entrepreneurship and Commerce in IT - 07 - Introduction to E-Commerce I - e-c...
Entrepreneurship and Commerce in IT - 07 - Introduction to E-Commerce I - e-c...
Sachintha Gunasena
 
Entrepreneurship and Commerce in IT - 06 - Funding, Expanding, and Exit Strat...
Entrepreneurship and Commerce in IT - 06 - Funding, Expanding, and Exit Strat...Entrepreneurship and Commerce in IT - 06 - Funding, Expanding, and Exit Strat...
Entrepreneurship and Commerce in IT - 06 - Funding, Expanding, and Exit Strat...
Sachintha Gunasena
 
Entrepreneurship and Commerce in IT - 05 - Marketing, Technology and Marketin...
Entrepreneurship and Commerce in IT - 05 - Marketing, Technology and Marketin...Entrepreneurship and Commerce in IT - 05 - Marketing, Technology and Marketin...
Entrepreneurship and Commerce in IT - 05 - Marketing, Technology and Marketin...
Sachintha Gunasena
 
Entrepreneurship & Commerce in IT - 01 - Introduction in to Entrepreneurship,...
Entrepreneurship & Commerce in IT - 01 - Introduction in to Entrepreneurship,...Entrepreneurship & Commerce in IT - 01 - Introduction in to Entrepreneurship,...
Entrepreneurship & Commerce in IT - 01 - Introduction in to Entrepreneurship,...
Sachintha Gunasena
 
Entrepreneurship & Commerce in IT - 02 - Basic Concepts of Entrepreneurship, ...
Entrepreneurship & Commerce in IT - 02 - Basic Concepts of Entrepreneurship, ...Entrepreneurship & Commerce in IT - 02 - Basic Concepts of Entrepreneurship, ...
Entrepreneurship & Commerce in IT - 02 - Basic Concepts of Entrepreneurship, ...
Sachintha Gunasena
 
Entrepreneurship & Commerce in IT - 04 - Marketing Plan, Marketing 7 P's, STP...
Entrepreneurship & Commerce in IT - 04 - Marketing Plan, Marketing 7 P's, STP...Entrepreneurship & Commerce in IT - 04 - Marketing Plan, Marketing 7 P's, STP...
Entrepreneurship & Commerce in IT - 04 - Marketing Plan, Marketing 7 P's, STP...
Sachintha Gunasena
 
Entrepreneurship & Commerce in IT - 03 - Writing a Business Plan, Creating a ...
Entrepreneurship & Commerce in IT - 03 - Writing a Business Plan, Creating a ...Entrepreneurship & Commerce in IT - 03 - Writing a Business Plan, Creating a ...
Entrepreneurship & Commerce in IT - 03 - Writing a Business Plan, Creating a ...
Sachintha Gunasena
 
Ad

Recently uploaded (20)

UPDASP a project coordination unit ......
UPDASP a project coordination unit ......UPDASP a project coordination unit ......
UPDASP a project coordination unit ......
withrj1
 
Artificial Intelligence Applications Across Industries
Artificial Intelligence Applications Across IndustriesArtificial Intelligence Applications Across Industries
Artificial Intelligence Applications Across Industries
SandeepKS52
 
Shell Skill Tree - LabEx Certification (LabEx)
Shell Skill Tree - LabEx Certification (LabEx)Shell Skill Tree - LabEx Certification (LabEx)
Shell Skill Tree - LabEx Certification (LabEx)
VICTOR MAESTRE RAMIREZ
 
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWSWomen in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
BradBedford3
 
Plooma is a writing platform to plan, write, and shape books your way
Plooma is a writing platform to plan, write, and shape books your wayPlooma is a writing platform to plan, write, and shape books your way
Plooma is a writing platform to plan, write, and shape books your way
Plooma
 
Reimagining Software Development and DevOps with Agentic AI
Reimagining Software Development and DevOps with Agentic AIReimagining Software Development and DevOps with Agentic AI
Reimagining Software Development and DevOps with Agentic AI
Maxim Salnikov
 
How the US Navy Approaches DevSecOps with Raise 2.0
How the US Navy Approaches DevSecOps with Raise 2.0How the US Navy Approaches DevSecOps with Raise 2.0
How the US Navy Approaches DevSecOps with Raise 2.0
Anchore
 
Generative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its ApplicationsGenerative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its Applications
SandeepKS52
 
SAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.pptSAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.ppt
MuhammadShaheryar36
 
Microsoft Business-230T01A-ENU-PowerPoint_01.pptx
Microsoft Business-230T01A-ENU-PowerPoint_01.pptxMicrosoft Business-230T01A-ENU-PowerPoint_01.pptx
Microsoft Business-230T01A-ENU-PowerPoint_01.pptx
soulamaabdoulaye128
 
Porting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 WebinarPorting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 Webinar
ICS
 
IBM Rational Unified Process For Software Engineering - Introduction
IBM Rational Unified Process For Software Engineering - IntroductionIBM Rational Unified Process For Software Engineering - Introduction
IBM Rational Unified Process For Software Engineering - Introduction
Gaurav Sharma
 
Transmission Media. (Computer Networks)
Transmission Media.  (Computer Networks)Transmission Media.  (Computer Networks)
Transmission Media. (Computer Networks)
S Pranav (Deepu)
 
Automated Migration of ESRI Geodatabases Using XML Control Files and FME
Automated Migration of ESRI Geodatabases Using XML Control Files and FMEAutomated Migration of ESRI Geodatabases Using XML Control Files and FME
Automated Migration of ESRI Geodatabases Using XML Control Files and FME
Safe Software
 
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Wondershare PDFelement Pro 11.4.20.3548 Crack Free DownloadWondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Puppy jhon
 
FME as an Orchestration Tool - Peak of Data & AI 2025
FME as an Orchestration Tool - Peak of Data & AI 2025FME as an Orchestration Tool - Peak of Data & AI 2025
FME as an Orchestration Tool - Peak of Data & AI 2025
Safe Software
 
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration KeySmadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
joybepari360
 
Advanced Token Development - Decentralized Innovation
Advanced Token Development - Decentralized InnovationAdvanced Token Development - Decentralized Innovation
Advanced Token Development - Decentralized Innovation
arohisinghas720
 
Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3
Gaurav Sharma
 
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
BradBedford3
 
UPDASP a project coordination unit ......
UPDASP a project coordination unit ......UPDASP a project coordination unit ......
UPDASP a project coordination unit ......
withrj1
 
Artificial Intelligence Applications Across Industries
Artificial Intelligence Applications Across IndustriesArtificial Intelligence Applications Across Industries
Artificial Intelligence Applications Across Industries
SandeepKS52
 
Shell Skill Tree - LabEx Certification (LabEx)
Shell Skill Tree - LabEx Certification (LabEx)Shell Skill Tree - LabEx Certification (LabEx)
Shell Skill Tree - LabEx Certification (LabEx)
VICTOR MAESTRE RAMIREZ
 
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWSWomen in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
BradBedford3
 
Plooma is a writing platform to plan, write, and shape books your way
Plooma is a writing platform to plan, write, and shape books your wayPlooma is a writing platform to plan, write, and shape books your way
Plooma is a writing platform to plan, write, and shape books your way
Plooma
 
Reimagining Software Development and DevOps with Agentic AI
Reimagining Software Development and DevOps with Agentic AIReimagining Software Development and DevOps with Agentic AI
Reimagining Software Development and DevOps with Agentic AI
Maxim Salnikov
 
How the US Navy Approaches DevSecOps with Raise 2.0
How the US Navy Approaches DevSecOps with Raise 2.0How the US Navy Approaches DevSecOps with Raise 2.0
How the US Navy Approaches DevSecOps with Raise 2.0
Anchore
 
Generative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its ApplicationsGenerative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its Applications
SandeepKS52
 
SAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.pptSAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.ppt
MuhammadShaheryar36
 
Microsoft Business-230T01A-ENU-PowerPoint_01.pptx
Microsoft Business-230T01A-ENU-PowerPoint_01.pptxMicrosoft Business-230T01A-ENU-PowerPoint_01.pptx
Microsoft Business-230T01A-ENU-PowerPoint_01.pptx
soulamaabdoulaye128
 
Porting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 WebinarPorting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 Webinar
ICS
 
IBM Rational Unified Process For Software Engineering - Introduction
IBM Rational Unified Process For Software Engineering - IntroductionIBM Rational Unified Process For Software Engineering - Introduction
IBM Rational Unified Process For Software Engineering - Introduction
Gaurav Sharma
 
Transmission Media. (Computer Networks)
Transmission Media.  (Computer Networks)Transmission Media.  (Computer Networks)
Transmission Media. (Computer Networks)
S Pranav (Deepu)
 
Automated Migration of ESRI Geodatabases Using XML Control Files and FME
Automated Migration of ESRI Geodatabases Using XML Control Files and FMEAutomated Migration of ESRI Geodatabases Using XML Control Files and FME
Automated Migration of ESRI Geodatabases Using XML Control Files and FME
Safe Software
 
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Wondershare PDFelement Pro 11.4.20.3548 Crack Free DownloadWondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Puppy jhon
 
FME as an Orchestration Tool - Peak of Data & AI 2025
FME as an Orchestration Tool - Peak of Data & AI 2025FME as an Orchestration Tool - Peak of Data & AI 2025
FME as an Orchestration Tool - Peak of Data & AI 2025
Safe Software
 
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration KeySmadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
joybepari360
 
Advanced Token Development - Decentralized Innovation
Advanced Token Development - Decentralized InnovationAdvanced Token Development - Decentralized Innovation
Advanced Token Development - Decentralized Innovation
arohisinghas720
 
Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3
Gaurav Sharma
 
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
BradBedford3
 

Concurrency Programming in Java - 01 - Introduction to Concurrency Programming

  • 2. Learning Outcomes Sachintha Gunasena MBCS http://lk.linkedin.com/in/sachinthadtg
  • 3. Learning Outcomes • Demonstrate foundational computing knowledge of concurrent systems, their performance opportunities and how to implement them using: • Java concurrent features and their semantics • Java packages and APIs for concurrent programs • Conventional synchronisation algorithms, data- structures and APIs • Wait-free and lock-free synchronisation controls.
  • 4. Learning Outcomes Cont.d • Apply knowledge of computing principles and technical skills to parallelise tasks to improve their performance and response characteristics by: • Using abstraction and computational thinking • Developing, implementing and testing the effectiveness of alternate Java programs with different levels of concurrency • Critiquing the approach used to solve a problem by evaluating its strengths and weaknesses
  • 6. Programming • the process of writing computer programs. • example • Output class First { public static void main(String[] arguments) { System.out.println("Let's do something using Java technology."); } }
  • 7. OOP • Object • An object is a software bundle of related state and behavior. Software objects are often used to model the real-world objects that you find in everyday life. This lesson explains how state and behavior are represented within an object, introduces the concept of data encapsulation, and explains the benefits of designing your software in this manner. • Class • A class is a blueprint or prototype from which objects are created. This section defines a class that models the state and behavior of a real-world object. It intentionally focuses on the basics, showing how even a simple class can cleanly model state and behavior. • Inheritance • Inheritance provides a powerful and natural mechanism for organizing and structuring your software. This section explains how classes inherit state and behavior from their superclasses, and explains how to derive one class from another using the simple syntax provided by the Java programming language.
  • 8. OOP Cont.d • Encapsulation • If a class disallows calling code from accessing internal object data and forces access through methods only, this is a strong form of abstraction or information hiding known as encapsulation • Interface • An interface is a contract between a class and the outside world. When a class implements an interface, it promises to provide the behavior published by that interface. This section defines a simple interface and explains the necessary changes for any class that implements it. • Package • A package is a namespace for organizing classes and interfaces in a logical manner. Placing your code into packages makes large software projects easier to manage. This section explains why this is useful, and introduces you to the Application Programming Interface (API) provided by the Java platform.
  • 9. Concurrency • a property of systems in which several computations are executing simultaneously, and potentially interacting with each other. • The computations may be executing on multiple cores in the same chip, preemptively time-shared threads on the same processor, or executed on physically separated processors. • A number of mathematical models have been developed for general concurrent computation including Petri nets, process calculi, the Parallel Random Access Machine model, the Actor model and the Reo Coordination Language.
  • 10. Concurrent Programming • Concurrent object-oriented programming is a programming paradigm which combines object- oriented programming (OOP) together with concurrency. • While numerous programming languages, such as Java, combine OOP with concurrency mechanisms like threads, the phrase "concurrent object-oriented programming" primarily refers to systems where objects themselves are a concurrency primitive, such as when objects are combined with the actor model.
  • 11. Parallel Computing • a form of computation in which many calculations are carried out simultaneously, operating on the principle that large problems can often be divided into smaller ones, which are then solved at the same time.
  • 12. Concurrent vs Parallel • you can have two threads (or processes) executing concurrently on the same core through context switching. • When the two threads (or processes) are executed on two different cores (or processors), you have parallelism. • in concurrency, parallelism is only "virtual", while the other true parallelism. • Therefore, every parallel program is concurrent, but the converse is not necessarily true
  • 13. Why Concurrency? • Efficiency • Time (load sharing) • Cost (resource sharing) • Availability • Multiple access • Convenience • • Perform several tasks at once • Modeling power • Describing systems that are inherently parallel
  • 14. Real World Example • Computer systems are used for modeling objects in the real world • Object-oriented programming • The world often includes parallel operation • example: • Limited number of seats on the same plane • Several booking agents active at the same time
  • 15. Terms • Multiprocessing • the use of more than one processing unit in a system • Parallel execution • processes running at the same time
  • 16. Terms Cont.d • Interleaving • several tasks active, only one running at a time • Multitasking • the OS runs interleaved executions • Concurrency • multiprocessing, multitasking, or any combination
  • 18. Why it matters? • The “end of Moore’s law as we knew it” has important implications on the software construction process • Computing is taking an irreversible step toward parallel architectures • Hardware construction of ever faster sequential CPUs has hit physical limits • Clock speed no longer increases for every new processor generation • Moore’s Law expresses itself as exponentially increasing number of processing cores per chip • If we want programs to run faster on the next processor generation, the software must exploit more concurrency
  • 20. Amdahl’s Law Cont.d • We go from 1 processor to n. What gain may we expect? • Amdahl’s law severely limits our hopes! • Define gain as: • speed up = ( 1 / (( 1-p)+( p/n)) ) • where p = parallelizable %; n= number of processors • Not everything can be parallelized!
  • 21. Types of Parallel Computation • Flynn’s taxonomy: classification of computer architectures • Considers relationship of instruction streams to data streams: • SISD: No parallelism (uniprocessor) • SIMD: Vector processor, GPU • MIMD: Multiprocessing (predominant today)
  • 22. MIMD Variants • SPMD (Single Program Multiple Data): • All processors run same program, but at independent speeds; no lockstep as in SIMD • MPMD (Multiple Program Multiple Data): • Often manager/worker strategy: manager distributes tasks, workers return result to manager
  • 23. Shared Memory Model • All processors share a common memory • Shared-memory communication Memory Processor 1 Processor 2 Processor 4 Processor 3
  • 24. Distributed Memory Model • Each processor has own local memory, inaccessible to others • Message passing communication • Common for SPMD architecture Process or Process or Process or Memory MemoryMemory Message Passing
  • 25. Client Server Model • Specific case of the distributed model • Examples: Database-centered systems, World-Wide Web Process or Process or Process or Memory Memory Memory
  • 26. SCOOP Mechanism • Simple Concurrent Object-Oriented Programming • Evolved through previous two decades; CACM (1993) and chap. 32 of Object-Oriented Software Construction, 2nd edition, 1997 • Prototype-implementation at ETH in 2007 • Implementation integrated within EiffelStudio in 2011 (by Eiffel Software) • Current reference: ETH PhD Thesis by Piotr Nienaltowski, 2008; articles by Benjamin Morandi, Sebastian Nanz and Bertrand Meyer, 2010-2011
  • 27. SCOOP Preview: a sequential program transfer (source, target: ACCOUNT; amount: INTEGER) -- If possible, transfer amount from source to target. do if source.balance >= amount then source.withdraw (amount) target.deposit (amount) end end Typical calls: transfer (acc1, acc2, 100) transfer (acc1, acc3, 100)
  • 28. In a concurrent setting, using SCOOP transfer (source, target: separate ACCOUNT; amount: INTEGER) -- If possible, transfer amount from source to target. do if source.balance >= amount then source.withdraw (amount) target.deposit (amount) end end Typical calls: transfer (acc1, acc2, 100) transfer (acc1, acc3, 100)
  • 29. A better SCOOP version transfer (source, target: separate ACCOUNT; amount: INTEGER) -- Transfer amount from source to target. require source.balance >= amount do source.withdraw (amount) target.deposit (amount) ensure source.balance = old source.balance – amount target.balance = old target.balance + amount end
  • 30. Dining Philosophers • find out about it…
  • 32. Sequential Programming • Used to be messy • Still hard but key improvements: • Structured programming • Data abstraction & object technology • Design by Contract • Genericity, multiple inheritance • Architectural techniques
  • 33. Concurrent Programming • Used to be messy • Example: threading models in most popular approaches • Development level: sixties/seventies • Only understandable through operational reasoning
  • 34. References • http://www.javaworld.com/article/2078679/java-concurrency/java-concurrency-modern- threading-for-not-quite-beginners.html • https://books.google.mv/books?id=- x1S4neCSOYC&pg=PA5&lpg=PA5&dq=what+is+using+concurrency+constructs&source=bl&ot s=Dxdk47Ddy- &sig=ZxzRD163royyROmEOF2lAtSZBz8&hl=en&sa=X&ved=0CEkQ6AEwBmoVChMIx- rc1ZbYxwIVQQeOCh3LkguH#v=onepage&q=what%20is%20using%20concurrency%20constru cts&f=false • http://book.realworldhaskell.org/read/concurrent-and-multicore-programming.html • https://books.google.mv/books?id=mHozgJ7ngq0C&pg=PA1&lpg=PA1&dq=what+is+using+con currency+constructs&source=bl&ots=TOT_g- IESw&sig=xSG7JzGquRD9NZmnbkt6tv6Vr2A&hl=en&sa=X&ved=0CFcQ6AEwCWoVChMIx- rc1ZbYxwIVQQeOCh3LkguH#v=onepage&q=what%20is%20using%20concurrency%20constru cts&f=false • http://gee.cs.oswego.edu/dl/cpj/mechanics.html • Read stack overflow / java documentation / etc
  • 35. Next Up… • Concurrent Programming… Sachintha Gunasena MBCS http://lk.linkedin.com/in/sachinthadtg
  • 36. Thank you. Sachintha Gunasena MBCS http://lk.linkedin.com/in/sachinthadtg