SlideShare une entreprise Scribd logo
1  sur  50
Télécharger pour lire hors ligne
Facts about multithreading
that'll keep you up at night
Guy Baron, Director Mobile @ Vonage, Codemotion Tel Aviv 2017
Wikipedia
multithreading is the ability of a central processing unit (CPU) to
execute multiple processes or threads concurrently
Advantages
• Utilize more CPU power by reducing the impact of delaying
operations such as IO operations
• If a thread cannot use all the computing resources of the CPU
(because instructions depend on each other's result), running
another thread may prevent those resources from becoming idle
Common Issues
T1 IO IO
Time
PROCESSING
Too Many Threads
T2
T1 IO IO
Time
PROCESSING CONTEXT SWITCH
Too Many Threads
T3
T2
T1 IO IO
Time
PROCESSING CONTEXT SWITCH
Too Many Threads
T4
T3
T2
T1 IO
Time
PROCESSING CONTEXT SWITCH
Too Many Threads
T5
T4
T3
T2
T1 IO
Time
PROCESSING CONTEXT SWITCH
Too Many Threads
Race condition
Race conditions arise in software when an application depends on the
sequence or timing of processes or threads for it to operate properly
T1 Memory T2
i++; int i = 0; i++;
0 0
1 0
1 1
1 1
1 2
2 2
read
Increment
write
read
write
Increment
T1 Memory T2
i++; int i = 0; i++;
0 0
1 0
1 0 0
1 1 0
1 1
1 1
read
Increment
write
read
write
Increment
Deadlock
A deadlock is a state in which each member of a group of actions, is
waiting for some other member to release a lock.
T1
T2
A B
T1
A
T2
B
T1
T2
A B
T1
T2
A B
T1
T2
A B
Priority Inversion
A problematic scenario in scheduling in which a high priority task is indirectly
preempted by a lower priority task effectively "inverting" the relative priorities of the two
tasks.
A
High priority
Med priority
Low priority
A
High priority
Med priority
Low priority
A
High priority
Med priority
Low priority
Uncommon issues
64-bit values
(Java) single write to a non-volatile long or double value is treated as
two separate writes: one to each 32-bit half.
This can result in a situation where a thread sees the first 32 bits of a
64-bit value from one write, and the second 32 bits from another write.
64-bit values
Memory
1 1 1 1 1 1 1 1
value1
2 2 2 2 2 2 2 2
value2
64-bit values
1 1 1 1
Memory
1 1 1 1 1 1 1 1
value1
2 2 2 2 2 2 2 2
value2
64-bit values
2 2 2 2
Memory
1 1 1 1 1 1 1 1
value1
2 2 2 2 2 2 2 2
value2
64-bit values
2 2 2 2 2 2 2 2
Memory
1 1 1 1 1 1 1 1
value1
2 2 2 2 2 2 2 2
value2
64-bit values
1 1 1 1 2 2 2 2
Memory
1 1 1 1 1 1 1 1
value1
2 2 2 2 2 2 2 2
value2
int x = 0;

boolean finished = false;
void executeOnCpu1() {

x = 10;

finished = true;

}
void executeOnCpu2() {

while (!finished) {}

System.out.print(x);

}
Take a moment to read the code… All modern CPUs have multiple
levels of CPU caches
Cache 1
Memory
int x = 0;

boolean finished = false;
void executeOnCpu1() {

x = 10;

finished = true;

}
void executeOnCpu2() {

while (!finished) {}

System.out.print(x);

}
x = 0;

finished = false;
Cache 2
x = 0;

finished = false;
Cache 1
Memory
int x = 0;

boolean finished = false;
void executeOnCpu1() {

x = 10;

finished = true;

}
void executeOnCpu2() {

while (!finished) {}

System.out.print(x);

}
x = 10;

finished = false;
Cache 2
x = 0;

finished = false;
Cache 1
Memory
int x = 10;

boolean finished = false;
void executeOnCpu1() {

x = 10;

finished = true;

}
void executeOnCpu2() {

while (!finished) {}

System.out.print(x);

}
x = 10;

finished = false;
Cache 2
x = 0;

finished = false;
X
Cache 1
Memory
int x = 10;

boolean finished = false;
void executeOnCpu1() {

x = 10;

finished = true;

}
void executeOnCpu2() {

while (!finished) {}

System.out.print(x);

}
x = 10;

finished = true;
Cache 2
x = 0;

finished = false;
Cache 1
Memory
int x = 10;

boolean finished = true;
void executeOnCpu1() {

x = 10;

finished = true;

}
void executeOnCpu2() {

while (!finished) {}

System.out.print(x);

}
x = 10;

finished = true;
Cache 2
x = 0;

finished = false;
finished
Cache 1
Memory
int x = 10;

boolean finished = true;
void executeOnCpu1() {

x = 10;

finished = true;

}
void executeOnCpu2() {

while (!finished) {}

System.out.print(x);

}
x = 10;

finished = true;
Cache 2
x = 0;

finished = false;
?
Cache 1
Memory
int x = 10;

boolean finished = true;
void executeOnCpu1() {

x = 10;

finished = true;

}
void executeOnCpu2() {

while (!finished) {}

System.out.print(x);

}
x = 10;

finished = true;
Cache 2
x = 0;

finished = true;
finished
Cache 1
Memory
int x = 10;

boolean finished = true;
void executeOnCpu1() {

x = 10;

finished = true;

}
void executeOnCpu2() {

while (!finished) {}

System.out.print(0);

}
x = 10;

finished = true;
Cache 2
x = 0;

finished = true;
Take a moment to read the code…
int orderOfEvaluation() {

return f1() + f2() + f3();

}
int orderOfEvaluationExplicit?() {

return (f1() + f2()) + f3();

}
int orderOfEvaluationExplicit() {

return f1() + f2() + f3();

}
class NoOrder {

int value = 1;



int f1() { return this.value; }



int f2() { return this.value; }



int f3() {

//...

this.value = 10;

//...

return this.value;

}

}
int orderOfEvaluationExplicit() {

return 1 + f2() + f3();

}
class NoOrder {

int value = 1;



int f1() { return this.value; }



int f2() { return this.value; }



int f3() {

//...

this.value = 10;

//...

return this.value;

}

}
int orderOfEvaluationExplicit() {

return 1 + 1 + f3();

}
class NoOrder {

int value = 1;



int f1() { return this.value; }



int f2() { return this.value; }



int f3() {

//...

this.value = 10;

//...

return this.value;

}

}
int orderOfEvaluationExplicit() {

return 1 + 1 + 10;

}
class NoOrder {

int value = 1;



int f1() { return this.value; }



int f2() { return this.value; }



int f3() {

//...

this.value = 10;

//...

return this.value;

}

}
The compiler can
evaluate operands in
any order (C++)
int orderOfEvaluationExplicit() {

return f1() + f2() + f3();

}
class NoOrder {

int value = 1;



int f1() { return this.value; }



int f2() { return this.value; }



int f3() {

//...

this.value = 10;

//...

return this.value;

}

}
int orderOfEvaluationExplicit() {

return f1() + f2() + 10;

}
class NoOrder {

int value = 1;



int f1() { return this.value; }



int f2() { return this.value; }



int f3() {

//...

this.value = 10;

//...

return this.value;

}

}
int orderOfEvaluationExplicit() {

return f1() + 10 + 10;

}
class NoOrder {

int value = 1;



int f1() { return this.value; }



int f2() { return this.value; }



int f3() {

//...

this.value = 10;

//...

return this.value;

}

}
int orderOfEvaluationExplicit() {

return 10 + 10 + 10;

}
class NoOrder {

int value = 1;



int f1() { return this.value; }



int f2() { return this.value; }



int f3() {

//...

this.value = 10;

//...

return this.value;

}

}
Thank you
We are hiring…

Contenu connexe

Tendances

Ownership System in Rust
Ownership System in RustOwnership System in Rust
Ownership System in RustChih-Hsuan Kuo
 
Конверсия управляемых языков в неуправляемые
Конверсия управляемых языков в неуправляемыеКонверсия управляемых языков в неуправляемые
Конверсия управляемых языков в неуправляемыеPlatonov Sergey
 
Csw2016 gong pwn_a_nexus_device_with_a_single_vulnerability
Csw2016 gong pwn_a_nexus_device_with_a_single_vulnerabilityCsw2016 gong pwn_a_nexus_device_with_a_single_vulnerability
Csw2016 gong pwn_a_nexus_device_with_a_single_vulnerabilityCanSecWest
 
Zn task - defcon russia 20
Zn task  - defcon russia 20Zn task  - defcon russia 20
Zn task - defcon russia 20DefconRussia
 
Preparation for mit ose lab4
Preparation for mit ose lab4Preparation for mit ose lab4
Preparation for mit ose lab4Benux Wei
 
Pwning in c++ (basic)
Pwning in c++ (basic)Pwning in c++ (basic)
Pwning in c++ (basic)Angel Boy
 
Triton and Symbolic execution on GDB@DEF CON China
Triton and Symbolic execution on GDB@DEF CON ChinaTriton and Symbolic execution on GDB@DEF CON China
Triton and Symbolic execution on GDB@DEF CON ChinaWei-Bo Chen
 
Advanced cfg bypass on adobe flash player 18 defcon russia 23
Advanced cfg bypass on adobe flash player 18 defcon russia 23Advanced cfg bypass on adobe flash player 18 defcon russia 23
Advanced cfg bypass on adobe flash player 18 defcon russia 23DefconRussia
 
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
Evgeniy Muralev, Mark Vince, Working with the compiler, not against itEvgeniy Muralev, Mark Vince, Working with the compiler, not against it
Evgeniy Muralev, Mark Vince, Working with the compiler, not against itSergey Platonov
 
Vm ware fuzzing - defcon russia 20
Vm ware fuzzing  - defcon russia 20Vm ware fuzzing  - defcon russia 20
Vm ware fuzzing - defcon russia 20DefconRussia
 
The Ring programming language version 1.5.3 book - Part 25 of 184
The Ring programming language version 1.5.3 book - Part 25 of 184The Ring programming language version 1.5.3 book - Part 25 of 184
The Ring programming language version 1.5.3 book - Part 25 of 184Mahmoud Samir Fayed
 
Csw2016 gawlik bypassing_differentdefenseschemes
Csw2016 gawlik bypassing_differentdefenseschemesCsw2016 gawlik bypassing_differentdefenseschemes
Csw2016 gawlik bypassing_differentdefenseschemesCanSecWest
 
Exploitation of counter overflows in the Linux kernel
Exploitation of counter overflows in the Linux kernelExploitation of counter overflows in the Linux kernel
Exploitation of counter overflows in the Linux kernelVitaly Nikolenko
 
from Binary to Binary: How Qemu Works
from Binary to Binary: How Qemu Worksfrom Binary to Binary: How Qemu Works
from Binary to Binary: How Qemu WorksZhen Wei
 
A look into the sanitizer family (ASAN & UBSAN) by Akul Pillai
A look into the sanitizer family (ASAN & UBSAN) by Akul PillaiA look into the sanitizer family (ASAN & UBSAN) by Akul Pillai
A look into the sanitizer family (ASAN & UBSAN) by Akul PillaiCysinfo Cyber Security Community
 
Functional Reactive Programming / Compositional Event Systems
Functional Reactive Programming / Compositional Event SystemsFunctional Reactive Programming / Compositional Event Systems
Functional Reactive Programming / Compositional Event SystemsLeonardo Borges
 
What the &~#@<!? (Pointers in Rust)
What the &~#@<!? (Pointers in Rust)What the &~#@<!? (Pointers in Rust)
What the &~#@<!? (Pointers in Rust)David Evans
 

Tendances (20)

Ownership System in Rust
Ownership System in RustOwnership System in Rust
Ownership System in Rust
 
Конверсия управляемых языков в неуправляемые
Конверсия управляемых языков в неуправляемыеКонверсия управляемых языков в неуправляемые
Конверсия управляемых языков в неуправляемые
 
Csw2016 gong pwn_a_nexus_device_with_a_single_vulnerability
Csw2016 gong pwn_a_nexus_device_with_a_single_vulnerabilityCsw2016 gong pwn_a_nexus_device_with_a_single_vulnerability
Csw2016 gong pwn_a_nexus_device_with_a_single_vulnerability
 
Zn task - defcon russia 20
Zn task  - defcon russia 20Zn task  - defcon russia 20
Zn task - defcon russia 20
 
Preparation for mit ose lab4
Preparation for mit ose lab4Preparation for mit ose lab4
Preparation for mit ose lab4
 
System Calls
System CallsSystem Calls
System Calls
 
Pwning in c++ (basic)
Pwning in c++ (basic)Pwning in c++ (basic)
Pwning in c++ (basic)
 
Triton and Symbolic execution on GDB@DEF CON China
Triton and Symbolic execution on GDB@DEF CON ChinaTriton and Symbolic execution on GDB@DEF CON China
Triton and Symbolic execution on GDB@DEF CON China
 
Advanced cfg bypass on adobe flash player 18 defcon russia 23
Advanced cfg bypass on adobe flash player 18 defcon russia 23Advanced cfg bypass on adobe flash player 18 defcon russia 23
Advanced cfg bypass on adobe flash player 18 defcon russia 23
 
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
Evgeniy Muralev, Mark Vince, Working with the compiler, not against itEvgeniy Muralev, Mark Vince, Working with the compiler, not against it
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
 
Joel Falcou, Boost.SIMD
Joel Falcou, Boost.SIMDJoel Falcou, Boost.SIMD
Joel Falcou, Boost.SIMD
 
Vm ware fuzzing - defcon russia 20
Vm ware fuzzing  - defcon russia 20Vm ware fuzzing  - defcon russia 20
Vm ware fuzzing - defcon russia 20
 
The Ring programming language version 1.5.3 book - Part 25 of 184
The Ring programming language version 1.5.3 book - Part 25 of 184The Ring programming language version 1.5.3 book - Part 25 of 184
The Ring programming language version 1.5.3 book - Part 25 of 184
 
Csw2016 gawlik bypassing_differentdefenseschemes
Csw2016 gawlik bypassing_differentdefenseschemesCsw2016 gawlik bypassing_differentdefenseschemes
Csw2016 gawlik bypassing_differentdefenseschemes
 
Exploitation of counter overflows in the Linux kernel
Exploitation of counter overflows in the Linux kernelExploitation of counter overflows in the Linux kernel
Exploitation of counter overflows in the Linux kernel
 
Full Stack Clojure
Full Stack ClojureFull Stack Clojure
Full Stack Clojure
 
from Binary to Binary: How Qemu Works
from Binary to Binary: How Qemu Worksfrom Binary to Binary: How Qemu Works
from Binary to Binary: How Qemu Works
 
A look into the sanitizer family (ASAN & UBSAN) by Akul Pillai
A look into the sanitizer family (ASAN & UBSAN) by Akul PillaiA look into the sanitizer family (ASAN & UBSAN) by Akul Pillai
A look into the sanitizer family (ASAN & UBSAN) by Akul Pillai
 
Functional Reactive Programming / Compositional Event Systems
Functional Reactive Programming / Compositional Event SystemsFunctional Reactive Programming / Compositional Event Systems
Functional Reactive Programming / Compositional Event Systems
 
What the &~#@<!? (Pointers in Rust)
What the &~#@<!? (Pointers in Rust)What the &~#@<!? (Pointers in Rust)
What the &~#@<!? (Pointers in Rust)
 

Similaire à Facts about multithreading that'll keep you up at night - Guy Bar on, Vonage

how to reuse code
how to reuse codehow to reuse code
how to reuse codejleed1
 
GPU Programming on CPU - Using C++AMP
GPU Programming on CPU - Using C++AMPGPU Programming on CPU - Using C++AMP
GPU Programming on CPU - Using C++AMPMiller Lee
 
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...corehard_by
 
Giorgio zoppi cpp11concurrency
Giorgio zoppi cpp11concurrencyGiorgio zoppi cpp11concurrency
Giorgio zoppi cpp11concurrencyGiorgio Zoppi
 
Yoyak ScalaDays 2015
Yoyak ScalaDays 2015Yoyak ScalaDays 2015
Yoyak ScalaDays 2015ihji
 
Austin c-c++-meetup-feb2018-spectre
Austin c-c++-meetup-feb2018-spectreAustin c-c++-meetup-feb2018-spectre
Austin c-c++-meetup-feb2018-spectreKim Phillips
 
The Ring programming language version 1.10 book - Part 38 of 212
The Ring programming language version 1.10 book - Part 38 of 212The Ring programming language version 1.10 book - Part 38 of 212
The Ring programming language version 1.10 book - Part 38 of 212Mahmoud Samir Fayed
 
PVS-Studio 5.00, a solution for developers of modern resource-intensive appl...
PVS-Studio 5.00, a solution for developers of modern resource-intensive appl...PVS-Studio 5.00, a solution for developers of modern resource-intensive appl...
PVS-Studio 5.00, a solution for developers of modern resource-intensive appl...Andrey Karpov
 
[grcpp] Refactoring for testability c++
[grcpp] Refactoring for testability c++[grcpp] Refactoring for testability c++
[grcpp] Refactoring for testability c++Dimitrios Platis
 
Java Foundations: Data Types and Type Conversion
Java Foundations: Data Types and Type ConversionJava Foundations: Data Types and Type Conversion
Java Foundations: Data Types and Type ConversionSvetlin Nakov
 

Similaire à Facts about multithreading that'll keep you up at night - Guy Bar on, Vonage (20)

how to reuse code
how to reuse codehow to reuse code
how to reuse code
 
GPU Programming on CPU - Using C++AMP
GPU Programming on CPU - Using C++AMPGPU Programming on CPU - Using C++AMP
GPU Programming on CPU - Using C++AMP
 
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...
 
06.Loops
06.Loops06.Loops
06.Loops
 
Le langage rust
Le langage rustLe langage rust
Le langage rust
 
DSA 103 Object Oriented Programming :: Week 3
DSA 103 Object Oriented Programming :: Week 3DSA 103 Object Oriented Programming :: Week 3
DSA 103 Object Oriented Programming :: Week 3
 
MUST CS101 Lab11
MUST CS101 Lab11 MUST CS101 Lab11
MUST CS101 Lab11
 
Giorgio zoppi cpp11concurrency
Giorgio zoppi cpp11concurrencyGiorgio zoppi cpp11concurrency
Giorgio zoppi cpp11concurrency
 
Yoyak ScalaDays 2015
Yoyak ScalaDays 2015Yoyak ScalaDays 2015
Yoyak ScalaDays 2015
 
Austin c-c++-meetup-feb2018-spectre
Austin c-c++-meetup-feb2018-spectreAustin c-c++-meetup-feb2018-spectre
Austin c-c++-meetup-feb2018-spectre
 
Staging driver sins
Staging driver sinsStaging driver sins
Staging driver sins
 
The Ring programming language version 1.10 book - Part 38 of 212
The Ring programming language version 1.10 book - Part 38 of 212The Ring programming language version 1.10 book - Part 38 of 212
The Ring programming language version 1.10 book - Part 38 of 212
 
Quiz 9
Quiz 9Quiz 9
Quiz 9
 
PVS-Studio 5.00, a solution for developers of modern resource-intensive appl...
PVS-Studio 5.00, a solution for developers of modern resource-intensive appl...PVS-Studio 5.00, a solution for developers of modern resource-intensive appl...
PVS-Studio 5.00, a solution for developers of modern resource-intensive appl...
 
[grcpp] Refactoring for testability c++
[grcpp] Refactoring for testability c++[grcpp] Refactoring for testability c++
[grcpp] Refactoring for testability c++
 
Ch4
Ch4Ch4
Ch4
 
Java Foundations: Data Types and Type Conversion
Java Foundations: Data Types and Type ConversionJava Foundations: Data Types and Type Conversion
Java Foundations: Data Types and Type Conversion
 
Microkernel Development
Microkernel DevelopmentMicrokernel Development
Microkernel Development
 
C tutorial
C tutorialC tutorial
C tutorial
 
C tutorial
C tutorialC tutorial
C tutorial
 

Plus de Codemotion Tel Aviv

Keynote: Trends in Modern Application Development - Gilly Dekel, IBM
Keynote: Trends in Modern Application Development - Gilly Dekel, IBMKeynote: Trends in Modern Application Development - Gilly Dekel, IBM
Keynote: Trends in Modern Application Development - Gilly Dekel, IBMCodemotion Tel Aviv
 
Angular is one fire(base)! - Shmuela Jacobs
Angular is one fire(base)! - Shmuela JacobsAngular is one fire(base)! - Shmuela Jacobs
Angular is one fire(base)! - Shmuela JacobsCodemotion Tel Aviv
 
Demystifying docker networking black magic - Lorenzo Fontana, Kiratech
Demystifying docker networking black magic - Lorenzo Fontana, KiratechDemystifying docker networking black magic - Lorenzo Fontana, Kiratech
Demystifying docker networking black magic - Lorenzo Fontana, KiratechCodemotion Tel Aviv
 
Faster deep learning solutions from training to inference - Amitai Armon & Ni...
Faster deep learning solutions from training to inference - Amitai Armon & Ni...Faster deep learning solutions from training to inference - Amitai Armon & Ni...
Faster deep learning solutions from training to inference - Amitai Armon & Ni...Codemotion Tel Aviv
 
Master the Art of the AST (and Take Control of Your JS!) - Yonatan Mevorach, ...
Master the Art of the AST (and Take Control of Your JS!) - Yonatan Mevorach, ...Master the Art of the AST (and Take Control of Your JS!) - Yonatan Mevorach, ...
Master the Art of the AST (and Take Control of Your JS!) - Yonatan Mevorach, ...Codemotion Tel Aviv
 
Unleash the power of angular Reactive Forms - Nir Kaufman, 500Tech
Unleash the power of angular Reactive Forms - Nir Kaufman, 500TechUnleash the power of angular Reactive Forms - Nir Kaufman, 500Tech
Unleash the power of angular Reactive Forms - Nir Kaufman, 500TechCodemotion Tel Aviv
 
Can we build an Azure IoT controlled device in less than 40 minutes that cost...
Can we build an Azure IoT controlled device in less than 40 minutes that cost...Can we build an Azure IoT controlled device in less than 40 minutes that cost...
Can we build an Azure IoT controlled device in less than 40 minutes that cost...Codemotion Tel Aviv
 
Actors and Microservices - Can two walk together? - Rotem Hermon, Gigya
Actors and Microservices - Can two walk together? - Rotem Hermon, GigyaActors and Microservices - Can two walk together? - Rotem Hermon, Gigya
Actors and Microservices - Can two walk together? - Rotem Hermon, GigyaCodemotion Tel Aviv
 
How to Leverage Machine Learning (R, Hadoop, Spark, H2O) for Real Time Proces...
How to Leverage Machine Learning (R, Hadoop, Spark, H2O) for Real Time Proces...How to Leverage Machine Learning (R, Hadoop, Spark, H2O) for Real Time Proces...
How to Leverage Machine Learning (R, Hadoop, Spark, H2O) for Real Time Proces...Codemotion Tel Aviv
 
My Minecraft Smart Home: Prototyping the internet of uncanny things - Sascha ...
My Minecraft Smart Home: Prototyping the internet of uncanny things - Sascha ...My Minecraft Smart Home: Prototyping the internet of uncanny things - Sascha ...
My Minecraft Smart Home: Prototyping the internet of uncanny things - Sascha ...Codemotion Tel Aviv
 
Distributed Systems explained (with NodeJS) - Bruno Bossola, JUG Torino
Distributed Systems explained (with NodeJS) - Bruno Bossola, JUG TorinoDistributed Systems explained (with NodeJS) - Bruno Bossola, JUG Torino
Distributed Systems explained (with NodeJS) - Bruno Bossola, JUG TorinoCodemotion Tel Aviv
 
Containerised ASP.NET Core apps with Kubernetes
Containerised ASP.NET Core apps with KubernetesContainerised ASP.NET Core apps with Kubernetes
Containerised ASP.NET Core apps with KubernetesCodemotion Tel Aviv
 
Fullstack DDD with ASP.NET Core and Anguar 2 - Ronald Harmsen, NForza
Fullstack DDD with ASP.NET Core and Anguar 2 - Ronald Harmsen, NForzaFullstack DDD with ASP.NET Core and Anguar 2 - Ronald Harmsen, NForza
Fullstack DDD with ASP.NET Core and Anguar 2 - Ronald Harmsen, NForzaCodemotion Tel Aviv
 
The Art of Decomposing Monoliths - Kfir Bloch, Wix
The Art of Decomposing Monoliths - Kfir Bloch, WixThe Art of Decomposing Monoliths - Kfir Bloch, Wix
The Art of Decomposing Monoliths - Kfir Bloch, WixCodemotion Tel Aviv
 
SOA Lessons Learnt (or Microservices done Better) - Sean Farmar, Particular S...
SOA Lessons Learnt (or Microservices done Better) - Sean Farmar, Particular S...SOA Lessons Learnt (or Microservices done Better) - Sean Farmar, Particular S...
SOA Lessons Learnt (or Microservices done Better) - Sean Farmar, Particular S...Codemotion Tel Aviv
 
S3, Cassandra or Outer Space? Dumping Time Series Data using Spark - Demi Ben...
S3, Cassandra or Outer Space? Dumping Time Series Data using Spark - Demi Ben...S3, Cassandra or Outer Space? Dumping Time Series Data using Spark - Demi Ben...
S3, Cassandra or Outer Space? Dumping Time Series Data using Spark - Demi Ben...Codemotion Tel Aviv
 
Getting Physical with Web Bluetooth - Uri Shaked, BlackBerry
Getting Physical with Web Bluetooth - Uri Shaked, BlackBerryGetting Physical with Web Bluetooth - Uri Shaked, BlackBerry
Getting Physical with Web Bluetooth - Uri Shaked, BlackBerryCodemotion Tel Aviv
 
Web based virtual reality - Tanay Pant, Mozilla
Web based virtual reality - Tanay Pant, MozillaWeb based virtual reality - Tanay Pant, Mozilla
Web based virtual reality - Tanay Pant, MozillaCodemotion Tel Aviv
 
Material Design Demytified - Ran Nachmany, Google
Material Design Demytified - Ran Nachmany, GoogleMaterial Design Demytified - Ran Nachmany, Google
Material Design Demytified - Ran Nachmany, GoogleCodemotion Tel Aviv
 
All the reasons for choosing react js that you didn't know about - Avi Marcus...
All the reasons for choosing react js that you didn't know about - Avi Marcus...All the reasons for choosing react js that you didn't know about - Avi Marcus...
All the reasons for choosing react js that you didn't know about - Avi Marcus...Codemotion Tel Aviv
 

Plus de Codemotion Tel Aviv (20)

Keynote: Trends in Modern Application Development - Gilly Dekel, IBM
Keynote: Trends in Modern Application Development - Gilly Dekel, IBMKeynote: Trends in Modern Application Development - Gilly Dekel, IBM
Keynote: Trends in Modern Application Development - Gilly Dekel, IBM
 
Angular is one fire(base)! - Shmuela Jacobs
Angular is one fire(base)! - Shmuela JacobsAngular is one fire(base)! - Shmuela Jacobs
Angular is one fire(base)! - Shmuela Jacobs
 
Demystifying docker networking black magic - Lorenzo Fontana, Kiratech
Demystifying docker networking black magic - Lorenzo Fontana, KiratechDemystifying docker networking black magic - Lorenzo Fontana, Kiratech
Demystifying docker networking black magic - Lorenzo Fontana, Kiratech
 
Faster deep learning solutions from training to inference - Amitai Armon & Ni...
Faster deep learning solutions from training to inference - Amitai Armon & Ni...Faster deep learning solutions from training to inference - Amitai Armon & Ni...
Faster deep learning solutions from training to inference - Amitai Armon & Ni...
 
Master the Art of the AST (and Take Control of Your JS!) - Yonatan Mevorach, ...
Master the Art of the AST (and Take Control of Your JS!) - Yonatan Mevorach, ...Master the Art of the AST (and Take Control of Your JS!) - Yonatan Mevorach, ...
Master the Art of the AST (and Take Control of Your JS!) - Yonatan Mevorach, ...
 
Unleash the power of angular Reactive Forms - Nir Kaufman, 500Tech
Unleash the power of angular Reactive Forms - Nir Kaufman, 500TechUnleash the power of angular Reactive Forms - Nir Kaufman, 500Tech
Unleash the power of angular Reactive Forms - Nir Kaufman, 500Tech
 
Can we build an Azure IoT controlled device in less than 40 minutes that cost...
Can we build an Azure IoT controlled device in less than 40 minutes that cost...Can we build an Azure IoT controlled device in less than 40 minutes that cost...
Can we build an Azure IoT controlled device in less than 40 minutes that cost...
 
Actors and Microservices - Can two walk together? - Rotem Hermon, Gigya
Actors and Microservices - Can two walk together? - Rotem Hermon, GigyaActors and Microservices - Can two walk together? - Rotem Hermon, Gigya
Actors and Microservices - Can two walk together? - Rotem Hermon, Gigya
 
How to Leverage Machine Learning (R, Hadoop, Spark, H2O) for Real Time Proces...
How to Leverage Machine Learning (R, Hadoop, Spark, H2O) for Real Time Proces...How to Leverage Machine Learning (R, Hadoop, Spark, H2O) for Real Time Proces...
How to Leverage Machine Learning (R, Hadoop, Spark, H2O) for Real Time Proces...
 
My Minecraft Smart Home: Prototyping the internet of uncanny things - Sascha ...
My Minecraft Smart Home: Prototyping the internet of uncanny things - Sascha ...My Minecraft Smart Home: Prototyping the internet of uncanny things - Sascha ...
My Minecraft Smart Home: Prototyping the internet of uncanny things - Sascha ...
 
Distributed Systems explained (with NodeJS) - Bruno Bossola, JUG Torino
Distributed Systems explained (with NodeJS) - Bruno Bossola, JUG TorinoDistributed Systems explained (with NodeJS) - Bruno Bossola, JUG Torino
Distributed Systems explained (with NodeJS) - Bruno Bossola, JUG Torino
 
Containerised ASP.NET Core apps with Kubernetes
Containerised ASP.NET Core apps with KubernetesContainerised ASP.NET Core apps with Kubernetes
Containerised ASP.NET Core apps with Kubernetes
 
Fullstack DDD with ASP.NET Core and Anguar 2 - Ronald Harmsen, NForza
Fullstack DDD with ASP.NET Core and Anguar 2 - Ronald Harmsen, NForzaFullstack DDD with ASP.NET Core and Anguar 2 - Ronald Harmsen, NForza
Fullstack DDD with ASP.NET Core and Anguar 2 - Ronald Harmsen, NForza
 
The Art of Decomposing Monoliths - Kfir Bloch, Wix
The Art of Decomposing Monoliths - Kfir Bloch, WixThe Art of Decomposing Monoliths - Kfir Bloch, Wix
The Art of Decomposing Monoliths - Kfir Bloch, Wix
 
SOA Lessons Learnt (or Microservices done Better) - Sean Farmar, Particular S...
SOA Lessons Learnt (or Microservices done Better) - Sean Farmar, Particular S...SOA Lessons Learnt (or Microservices done Better) - Sean Farmar, Particular S...
SOA Lessons Learnt (or Microservices done Better) - Sean Farmar, Particular S...
 
S3, Cassandra or Outer Space? Dumping Time Series Data using Spark - Demi Ben...
S3, Cassandra or Outer Space? Dumping Time Series Data using Spark - Demi Ben...S3, Cassandra or Outer Space? Dumping Time Series Data using Spark - Demi Ben...
S3, Cassandra or Outer Space? Dumping Time Series Data using Spark - Demi Ben...
 
Getting Physical with Web Bluetooth - Uri Shaked, BlackBerry
Getting Physical with Web Bluetooth - Uri Shaked, BlackBerryGetting Physical with Web Bluetooth - Uri Shaked, BlackBerry
Getting Physical with Web Bluetooth - Uri Shaked, BlackBerry
 
Web based virtual reality - Tanay Pant, Mozilla
Web based virtual reality - Tanay Pant, MozillaWeb based virtual reality - Tanay Pant, Mozilla
Web based virtual reality - Tanay Pant, Mozilla
 
Material Design Demytified - Ran Nachmany, Google
Material Design Demytified - Ran Nachmany, GoogleMaterial Design Demytified - Ran Nachmany, Google
Material Design Demytified - Ran Nachmany, Google
 
All the reasons for choosing react js that you didn't know about - Avi Marcus...
All the reasons for choosing react js that you didn't know about - Avi Marcus...All the reasons for choosing react js that you didn't know about - Avi Marcus...
All the reasons for choosing react js that you didn't know about - Avi Marcus...
 

Dernier

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 

Dernier (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 

Facts about multithreading that'll keep you up at night - Guy Bar on, Vonage

  • 1. Facts about multithreading that'll keep you up at night Guy Baron, Director Mobile @ Vonage, Codemotion Tel Aviv 2017
  • 2. Wikipedia multithreading is the ability of a central processing unit (CPU) to execute multiple processes or threads concurrently
  • 3. Advantages • Utilize more CPU power by reducing the impact of delaying operations such as IO operations • If a thread cannot use all the computing resources of the CPU (because instructions depend on each other's result), running another thread may prevent those resources from becoming idle
  • 6. T2 T1 IO IO Time PROCESSING CONTEXT SWITCH Too Many Threads
  • 7. T3 T2 T1 IO IO Time PROCESSING CONTEXT SWITCH Too Many Threads
  • 8. T4 T3 T2 T1 IO Time PROCESSING CONTEXT SWITCH Too Many Threads
  • 10. Race condition Race conditions arise in software when an application depends on the sequence or timing of processes or threads for it to operate properly
  • 11. T1 Memory T2 i++; int i = 0; i++; 0 0 1 0 1 1 1 1 1 2 2 2 read Increment write read write Increment
  • 12. T1 Memory T2 i++; int i = 0; i++; 0 0 1 0 1 0 0 1 1 0 1 1 1 1 read Increment write read write Increment
  • 13. Deadlock A deadlock is a state in which each member of a group of actions, is waiting for some other member to release a lock.
  • 19.
  • 20. Priority Inversion A problematic scenario in scheduling in which a high priority task is indirectly preempted by a lower priority task effectively "inverting" the relative priorities of the two tasks.
  • 24.
  • 26. 64-bit values (Java) single write to a non-volatile long or double value is treated as two separate writes: one to each 32-bit half. This can result in a situation where a thread sees the first 32 bits of a 64-bit value from one write, and the second 32 bits from another write.
  • 27. 64-bit values Memory 1 1 1 1 1 1 1 1 value1 2 2 2 2 2 2 2 2 value2
  • 28. 64-bit values 1 1 1 1 Memory 1 1 1 1 1 1 1 1 value1 2 2 2 2 2 2 2 2 value2
  • 29. 64-bit values 2 2 2 2 Memory 1 1 1 1 1 1 1 1 value1 2 2 2 2 2 2 2 2 value2
  • 30. 64-bit values 2 2 2 2 2 2 2 2 Memory 1 1 1 1 1 1 1 1 value1 2 2 2 2 2 2 2 2 value2
  • 31. 64-bit values 1 1 1 1 2 2 2 2 Memory 1 1 1 1 1 1 1 1 value1 2 2 2 2 2 2 2 2 value2
  • 32. int x = 0;
 boolean finished = false; void executeOnCpu1() {
 x = 10;
 finished = true;
 } void executeOnCpu2() {
 while (!finished) {}
 System.out.print(x);
 } Take a moment to read the code… All modern CPUs have multiple levels of CPU caches
  • 33. Cache 1 Memory int x = 0;
 boolean finished = false; void executeOnCpu1() {
 x = 10;
 finished = true;
 } void executeOnCpu2() {
 while (!finished) {}
 System.out.print(x);
 } x = 0;
 finished = false; Cache 2 x = 0;
 finished = false;
  • 34. Cache 1 Memory int x = 0;
 boolean finished = false; void executeOnCpu1() {
 x = 10;
 finished = true;
 } void executeOnCpu2() {
 while (!finished) {}
 System.out.print(x);
 } x = 10;
 finished = false; Cache 2 x = 0;
 finished = false;
  • 35. Cache 1 Memory int x = 10;
 boolean finished = false; void executeOnCpu1() {
 x = 10;
 finished = true;
 } void executeOnCpu2() {
 while (!finished) {}
 System.out.print(x);
 } x = 10;
 finished = false; Cache 2 x = 0;
 finished = false; X
  • 36. Cache 1 Memory int x = 10;
 boolean finished = false; void executeOnCpu1() {
 x = 10;
 finished = true;
 } void executeOnCpu2() {
 while (!finished) {}
 System.out.print(x);
 } x = 10;
 finished = true; Cache 2 x = 0;
 finished = false;
  • 37. Cache 1 Memory int x = 10;
 boolean finished = true; void executeOnCpu1() {
 x = 10;
 finished = true;
 } void executeOnCpu2() {
 while (!finished) {}
 System.out.print(x);
 } x = 10;
 finished = true; Cache 2 x = 0;
 finished = false; finished
  • 38. Cache 1 Memory int x = 10;
 boolean finished = true; void executeOnCpu1() {
 x = 10;
 finished = true;
 } void executeOnCpu2() {
 while (!finished) {}
 System.out.print(x);
 } x = 10;
 finished = true; Cache 2 x = 0;
 finished = false; ?
  • 39. Cache 1 Memory int x = 10;
 boolean finished = true; void executeOnCpu1() {
 x = 10;
 finished = true;
 } void executeOnCpu2() {
 while (!finished) {}
 System.out.print(x);
 } x = 10;
 finished = true; Cache 2 x = 0;
 finished = true; finished
  • 40. Cache 1 Memory int x = 10;
 boolean finished = true; void executeOnCpu1() {
 x = 10;
 finished = true;
 } void executeOnCpu2() {
 while (!finished) {}
 System.out.print(0);
 } x = 10;
 finished = true; Cache 2 x = 0;
 finished = true;
  • 41. Take a moment to read the code… int orderOfEvaluation() {
 return f1() + f2() + f3();
 } int orderOfEvaluationExplicit?() {
 return (f1() + f2()) + f3();
 }
  • 42. int orderOfEvaluationExplicit() {
 return f1() + f2() + f3();
 } class NoOrder {
 int value = 1;
 
 int f1() { return this.value; }
 
 int f2() { return this.value; }
 
 int f3() {
 //...
 this.value = 10;
 //...
 return this.value;
 }
 }
  • 43. int orderOfEvaluationExplicit() {
 return 1 + f2() + f3();
 } class NoOrder {
 int value = 1;
 
 int f1() { return this.value; }
 
 int f2() { return this.value; }
 
 int f3() {
 //...
 this.value = 10;
 //...
 return this.value;
 }
 }
  • 44. int orderOfEvaluationExplicit() {
 return 1 + 1 + f3();
 } class NoOrder {
 int value = 1;
 
 int f1() { return this.value; }
 
 int f2() { return this.value; }
 
 int f3() {
 //...
 this.value = 10;
 //...
 return this.value;
 }
 }
  • 45. int orderOfEvaluationExplicit() {
 return 1 + 1 + 10;
 } class NoOrder {
 int value = 1;
 
 int f1() { return this.value; }
 
 int f2() { return this.value; }
 
 int f3() {
 //...
 this.value = 10;
 //...
 return this.value;
 }
 } The compiler can evaluate operands in any order (C++)
  • 46. int orderOfEvaluationExplicit() {
 return f1() + f2() + f3();
 } class NoOrder {
 int value = 1;
 
 int f1() { return this.value; }
 
 int f2() { return this.value; }
 
 int f3() {
 //...
 this.value = 10;
 //...
 return this.value;
 }
 }
  • 47. int orderOfEvaluationExplicit() {
 return f1() + f2() + 10;
 } class NoOrder {
 int value = 1;
 
 int f1() { return this.value; }
 
 int f2() { return this.value; }
 
 int f3() {
 //...
 this.value = 10;
 //...
 return this.value;
 }
 }
  • 48. int orderOfEvaluationExplicit() {
 return f1() + 10 + 10;
 } class NoOrder {
 int value = 1;
 
 int f1() { return this.value; }
 
 int f2() { return this.value; }
 
 int f3() {
 //...
 this.value = 10;
 //...
 return this.value;
 }
 }
  • 49. int orderOfEvaluationExplicit() {
 return 10 + 10 + 10;
 } class NoOrder {
 int value = 1;
 
 int f1() { return this.value; }
 
 int f2() { return this.value; }
 
 int f3() {
 //...
 this.value = 10;
 //...
 return this.value;
 }
 }
  • 50. Thank you We are hiring…