Submit Search
Upload
Multithreading development with workers
•
0 likes
•
264 views
Giorgio Natili
Follow
Technology
Report
Share
Report
Share
1 of 55
Download now
Download to read offline
Recommended
Multithreading models.ppt
Multithreading models.ppt
Luis Goldster
Thread
Thread
Sajid Hussain
Networking threads
Networking threads
Nilesh Pawar
Threads .ppt
Threads .ppt
meet darji
4 threads
4 threads
Dr. Loganathan R
Operating system: threads(mulithreading,benefits of threads, types of thread)
Operating system: threads(mulithreading,benefits of threads, types of thread)
sonuu__
Treads
Treads
nayanashetty7
Concurrent/ parallel programming
Concurrent/ parallel programming
Tausun Akhtary
Recommended
Multithreading models.ppt
Multithreading models.ppt
Luis Goldster
Thread
Thread
Sajid Hussain
Networking threads
Networking threads
Nilesh Pawar
Threads .ppt
Threads .ppt
meet darji
4 threads
4 threads
Dr. Loganathan R
Operating system: threads(mulithreading,benefits of threads, types of thread)
Operating system: threads(mulithreading,benefits of threads, types of thread)
sonuu__
Treads
Treads
nayanashetty7
Concurrent/ parallel programming
Concurrent/ parallel programming
Tausun Akhtary
W-9.pptx
W-9.pptx
alianwarr
multithreadingppt.pptx
multithreadingppt.pptx
FardeenAzhar
Assignment-01.pptx
Assignment-01.pptx
HaiderZaman45
Thread (Operating System)
Thread (Operating System)
kiran Patel
Lecture 3 threads
Lecture 3 threads
Kumbirai Junior Muzavazi
Parallel and Distributed Computing chapter 3
Parallel and Distributed Computing chapter 3
AbdullahMunir32
15 threads
15 threads
myrajendra
Multithreading
Multithreading
WafaQKhan
Thread
Thread
sajidhuseyin
Lecture 3- Threads (1).pptx
Lecture 3- Threads (1).pptx
Amanuelmergia
Mulitthread
Mulitthread
DeepaR42
Operating system 20 threads
Operating system 20 threads
Vaibhav Khanna
Epc 3.ppt
Epc 3.ppt
CasmoletJ
Multithreading in java
Multithreading in java
Arafat Hossan
Java Thread & Multithreading
Java Thread & Multithreading
jehan1987
Multi threaded programming
Multi threaded programming
AnyapuPranav
Operating Systems & Applications
Operating Systems & Applications
Maulen Bale
Pthread
Pthread
Gopi Saiteja
Multithreaded Programming Part- I.pdf
Multithreaded Programming Part- I.pdf
Harika Pudugosula
OOP Lecture 20-MultiThreading.pptx
OOP Lecture 20-MultiThreading.pptx
Tanzila Kehkashan
Driving Assistant Solutions with Android
Driving Assistant Solutions with Android
Giorgio Natili
Isomorphic Reactive Programming
Isomorphic Reactive Programming
Giorgio Natili
More Related Content
Similar to Multithreading development with workers
W-9.pptx
W-9.pptx
alianwarr
multithreadingppt.pptx
multithreadingppt.pptx
FardeenAzhar
Assignment-01.pptx
Assignment-01.pptx
HaiderZaman45
Thread (Operating System)
Thread (Operating System)
kiran Patel
Lecture 3 threads
Lecture 3 threads
Kumbirai Junior Muzavazi
Parallel and Distributed Computing chapter 3
Parallel and Distributed Computing chapter 3
AbdullahMunir32
15 threads
15 threads
myrajendra
Multithreading
Multithreading
WafaQKhan
Thread
Thread
sajidhuseyin
Lecture 3- Threads (1).pptx
Lecture 3- Threads (1).pptx
Amanuelmergia
Mulitthread
Mulitthread
DeepaR42
Operating system 20 threads
Operating system 20 threads
Vaibhav Khanna
Epc 3.ppt
Epc 3.ppt
CasmoletJ
Multithreading in java
Multithreading in java
Arafat Hossan
Java Thread & Multithreading
Java Thread & Multithreading
jehan1987
Multi threaded programming
Multi threaded programming
AnyapuPranav
Operating Systems & Applications
Operating Systems & Applications
Maulen Bale
Pthread
Pthread
Gopi Saiteja
Multithreaded Programming Part- I.pdf
Multithreaded Programming Part- I.pdf
Harika Pudugosula
OOP Lecture 20-MultiThreading.pptx
OOP Lecture 20-MultiThreading.pptx
Tanzila Kehkashan
Similar to Multithreading development with workers
(20)
W-9.pptx
W-9.pptx
multithreadingppt.pptx
multithreadingppt.pptx
Assignment-01.pptx
Assignment-01.pptx
Thread (Operating System)
Thread (Operating System)
Lecture 3 threads
Lecture 3 threads
Parallel and Distributed Computing chapter 3
Parallel and Distributed Computing chapter 3
15 threads
15 threads
Multithreading
Multithreading
Thread
Thread
Lecture 3- Threads (1).pptx
Lecture 3- Threads (1).pptx
Mulitthread
Mulitthread
Operating system 20 threads
Operating system 20 threads
Epc 3.ppt
Epc 3.ppt
Multithreading in java
Multithreading in java
Java Thread & Multithreading
Java Thread & Multithreading
Multi threaded programming
Multi threaded programming
Operating Systems & Applications
Operating Systems & Applications
Pthread
Pthread
Multithreaded Programming Part- I.pdf
Multithreaded Programming Part- I.pdf
OOP Lecture 20-MultiThreading.pptx
OOP Lecture 20-MultiThreading.pptx
More from Giorgio Natili
Driving Assistant Solutions with Android
Driving Assistant Solutions with Android
Giorgio Natili
Isomorphic Reactive Programming
Isomorphic Reactive Programming
Giorgio Natili
Service worker API
Service worker API
Giorgio Natili
The Little Shop of TDD Horrors
The Little Shop of TDD Horrors
Giorgio Natili
I beacon mobile_tea
I beacon mobile_tea
Giorgio Natili
Android, getting started
Android, getting started
Giorgio Natili
Clear the UIViewController Mess
Clear the UIViewController Mess
Giorgio Natili
Big data and mobile
Big data and mobile
Giorgio Natili
The short path to ecma 6
The short path to ecma 6
Giorgio Natili
Jasmine 2.0
Jasmine 2.0
Giorgio Natili
Harmonik
Harmonik
Giorgio Natili
Mobile raspberry pi
Mobile raspberry pi
Giorgio Natili
WebRTC communication and wearable devices
WebRTC communication and wearable devices
Giorgio Natili
Ecma6 in 30 minutes
Ecma6 in 30 minutes
Giorgio Natili
TDD and PhoneGap
TDD and PhoneGap
Giorgio Natili
Undoable architectures
Undoable architectures
Giorgio Natili
Test first!
Test first!
Giorgio Natili
WebRTC and Mobile Integration
WebRTC and Mobile Integration
Giorgio Natili
Develop, test and debug cross platforms apps with PhoneGap
Develop, test and debug cross platforms apps with PhoneGap
Giorgio Natili
Test first
Test first
Giorgio Natili
More from Giorgio Natili
(20)
Driving Assistant Solutions with Android
Driving Assistant Solutions with Android
Isomorphic Reactive Programming
Isomorphic Reactive Programming
Service worker API
Service worker API
The Little Shop of TDD Horrors
The Little Shop of TDD Horrors
I beacon mobile_tea
I beacon mobile_tea
Android, getting started
Android, getting started
Clear the UIViewController Mess
Clear the UIViewController Mess
Big data and mobile
Big data and mobile
The short path to ecma 6
The short path to ecma 6
Jasmine 2.0
Jasmine 2.0
Harmonik
Harmonik
Mobile raspberry pi
Mobile raspberry pi
WebRTC communication and wearable devices
WebRTC communication and wearable devices
Ecma6 in 30 minutes
Ecma6 in 30 minutes
TDD and PhoneGap
TDD and PhoneGap
Undoable architectures
Undoable architectures
Test first!
Test first!
WebRTC and Mobile Integration
WebRTC and Mobile Integration
Develop, test and debug cross platforms apps with PhoneGap
Develop, test and debug cross platforms apps with PhoneGap
Test first
Test first
Recently uploaded
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
2toLead Limited
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
Malak Abu Hammad
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
soniya singh
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
Ridwan Fadjar
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
Delhi Call girls
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
Memoori
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
BookNet Canada
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
null - The Open Security Community
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
Hyundai Motor Group
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
ThousandEyes
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Enjoy Anytime
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
null - The Open Security Community
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
Allon Mureinik
The transition to renewables in India.pdf
The transition to renewables in India.pdf
Competition Advisory Services (India) LLP
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
Delhi Call girls
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
Deakin University
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
Scott Keck-Warren
Recently uploaded
(20)
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
The transition to renewables in India.pdf
The transition to renewables in India.pdf
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
Multithreading development with workers
1.
2.
About me • Front-end developer • Mobile developer •
Agile Coach / Mentor • Currently working in Cengage
3.
4.
5.
6.
What is Multithreading? Multi-Threading is the ability of a CPU to execute several threads of execution apparently at the same Multi-threading is a widespread programming and execution model that allows multiple threads to exist
7.
Multi ~ threading / tasking • Multitasking is a method by which multiple processes share common processing resources • Multithreading extends the idea of multitasking into applications
8.
Processes 8770 mdworker 0.0 00:00.11 4 0 54 75 6768K 5760K 0B 0B 104M 2467M 78770 195 sleeping • A process is an instance of a program in execution • Processes may be in one of five states: New, Ready, Running, Waiting, Terminated
9.
Threads A thread is the smallest sequence of programmed instructions that can be managed independently by
10.
Kind of Threads • User level threads (you can play safely with them) • Kernel level threads (less safely but still funny!) •
User level threads are in the scope of ActionScript and Flex
11.
Threads and Processes • A thread is contained inside a process • Multiple threads can exist within the same process and share resources such as memory
12.
Differences (1/2) • A thread is light weight taking lesser resources than a process • Process switching needs interaction with operating system while thread switching does not •
Each process executes the same code using its own resources, threads use same resources
13.
Differences (2/2) • While one thread is blocked and waiting, second thread in the same task can run • Multiple processes use more resources, multiple threaded processes use fewer resources •
Processes operate independently of the others, threads access other thread's data
14.
Multithreading vs Async • Async is the better indicated for doing heavy IO bound processing • Multithreading is better indicated with long running processes
15.
Trivial Parallelism Scenario: large number of independent computation-intensive tasks • Create a pool of threads and distribute the tasks into them (accordingly to available CPUs) • Create a master thread distribute the work and collect the results
16.
Performances • An extra thread means more setup/teardown costs • Implement multithreading only after having profiled your app •
Look for tasks with as few as possible dependencies
17.
Parallel Algorithms Algorithms that concurrently perform work on collections of data Fibonacci(n): 1 if n < 2: | thread A 2 return n | thread A 3 x = spawn Fibonacci(n-1) | thread A 4 y = spawn Fibonacci(n-2) | thread B
18.
Why Using Multithreading • To improve performances (quick and dirty answer!) • To avoid that the GUI suffers of the latency of event driven architecture
19.
Responsiveness • Keep heavy tasks outside the main thread is the traditional way to keep the app responsive • We actually lose overall performance due to the extra cost of context switching •
But the user experience is anyway improved
20.
21.
Essentials • Multithreading require carefully programming • Manage the queue of requests •
Coordinating the work of multiple threads • Don't access the UI from a not UI thread • Try to avoid calling out to external code while holding a lock
22.
Mutual Exclusion • Sometimes we want things to happen simultaneously, and sometimes not • Reasoning about concurrent computation is mostly reasoning about time •
Acquire and release shared members in order to grant access to one thread per time
23.
Implementing Mutex • Each critical section is associated with a unique Lock object • The access to the section is locked and unlocked when trying to enter the critical section
24.
Concurrent Objects • When more than one thread work together we are dealing with threads pools • When working with threads pools each thread should be paused and resumed •
Managing concurrency it's possible to avoid blocking threads slow down the exectuin time
25.
Handle Race Conditions • Is when two threads access the same location in memory at the same time (writing!) • A race condition is a kind of bug, that happens only with certain
26.
Avoid Deadlocks A deadlock occurs when the waiting process is still holding on to another resource that the first needs • Reduces the number of threads (keep things simple!) • Don't hold several locks at once •
Don't execute foreign code while holding a lock
27.
28.
Before Flash Player 11.3 While the underlying Flash Player and Operating System use threads, the execution model for Actions
29.
UI Blocking if(appUI.isSlow){ app.quality === 'shitty app' } • User interface not responsive • The expected frame rate drops significantly •
The user experience was dramatically impacted
30.
LocalConnection Trick • Load separate SWF in the page • Handle communication through the LocalConnection class
31.
Pseudo Threading • Involves ENTER_FRAME, getTimer() and some calculation • Not always reliable due to the getTimer() reliability •
Not simple to maintain
32.
Asynchronous Execution
33.
Workers, the Holy Grail! • Complete separate SWF • Independent DisplayList
34.
35.
The Worker Class • A Worker instance is a virtual instance of the Flash / AIR runtime • Each Worker controls and provides access to the lifecycle and data of a single worker •
A worker is just another SWF that’s running alongside your main SWF
36.
Worker Support if(Worker.isSupported){ } • Desktop (Flash Player + AIR) • Mobile (AIR on Android only, weird ?!?)
37.
Create a Worker WorkerDomain.current.createWorker(workerBytes); The workerBytes variable contains the ByteArray of an SWF, include it: • Using the [Embed] metatag to embed the .swf file in the app
38.
Isolation • Workers do not have access to the same memory, variables, and code • Workers run in separated Flash Player instances •
What is shared between workers is under your control
39.
Shared Properties setSharedProperty(key:String, value:*):void • Each worker can expose a set of properties to other workers • Each worker can get the value stored in a shared property (from another worker) •
Values are NOT passed by reference (AMF serialization)
40.
Referenced Data Types • Worker • MessageChannel
41.
MessageChannel while ( mainToBack.messageAvailable ){ mainToBack.receive(); } • Send one-way messages and data from one worker to another • Treats messages and related values as a queue
42.
Shared Memory • A Shareable ByteArray • To pass around a reference to your shared memory, you use the MessageChannel API •
When you pass a ByteArray, it is not serialized, just referenced • You can then pass anything you want between the workers (as raw binary data)
43.
Mutex var mutex:Mutex = new Mutex(); • Locks a particular block of memory or shared resource • A Mutex manages access using the concept of resource ownership
44.
Condition var condition:Condition = Condition(mutex); condition.wait(timeout:Number = -1); • Suspend the execution of a worker (i.e. thread) • Resume the worker execution unlocking the associated mutex
45.
46.
Terminology • Promise, is an object with a then method; it can have 3 states: pending, fulfilled, or rejected • Thenable is an object that defines a then method •
Reason is a value that indicates why a promise was rejected.
47.
A promise A promise represents the eventual result of an asynchronous operation The point of promises is to give us back functional composition and error bubbling in the async world
48.
Then A promise's then method accepts two arguments and return a promise promise.then(onFulfilled, onRejected);
49.
Deferred A deferred object can do the same as a promise object, but it has two functions to trigger the done() a
50.
Promises vs Deferred • The promise object does not have resolve() or reject() functions • A promise is something shared w/ other objects, while a deferred should be kept private
51.
Resolvers • Are used internally by Deferreds to create, resolve and reject Promises • Resolvers can propagate fulfillment and rejection
52.
53.
54.
Q&A
55.
Thanks Grazie! Graçias! Danke! Merci! !
Download now