SlideShare a Scribd company logo

Titanium - Making the most of your single thread

Ronald Treur
Ronald Treur
Ronald TreurSoftware & Internet Architect at Snowciety / Lost Particle

The native app development environments support multiple threads. Titanium however does not (out of the box), it only supports a single thread. In this presentaton, Ronald Treur will shortly explain how threading works and why this knowledge matters. But more important, he will show you how to keep heavy duty processes from blocking others.

Titanium - Making the most of your single thread

1 of 33
Download to read offline
Making the most of your
single thread

Titanium - Fundamentals
Congrats!
!

Your app is in the
hands of the public!
Your users click on buttons,
open windows, and at some
point someone touches a
button that results in…
Absolutely
Nothing.
He tries touching it three
times, before deciding, after
a mere few seconds, that
your app has crashed.

!

He kills your app.
Had he waited
for ‘but’ 5
seconds..
.. he would have noticed
three windows opening in
rapid succession. Three
identical windows, as he
would observe when using
the ‘back’-button.
What did you do wrong?
•

There’s no loading indicator showing

•

There is no mechanic in place to prevent additional
windows from opening
What did you do wrong?
•

There’s no loading indicator showing

•

There is no mechanic in place to prevent additional
windows from opening

•

But more important: You blocked the UI far too long!

You did not make the best use of your single
thread!
Ad

Recommended

Best Practices in apps development with Titanium Appcelerator
Best Practices in apps development with Titanium Appcelerator Best Practices in apps development with Titanium Appcelerator
Best Practices in apps development with Titanium Appcelerator Alessio Ricco
 
Rick Blalock: Your Apps are Leaking - Controlling Memory Leaks
Rick Blalock: Your Apps are Leaking - Controlling Memory LeaksRick Blalock: Your Apps are Leaking - Controlling Memory Leaks
Rick Blalock: Your Apps are Leaking - Controlling Memory LeaksAxway Appcelerator
 
Titanium appcelerator best practices
Titanium appcelerator best practicesTitanium appcelerator best practices
Titanium appcelerator best practicesAlessio Ricco
 
Java fx smart code econ
Java fx smart code econJava fx smart code econ
Java fx smart code econTom Schindl
 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScriptYakov Fain
 
React Native in Production
React Native in ProductionReact Native in Production
React Native in ProductionSeokjun Kim
 
The current state of web
The current state of webThe current state of web
The current state of webRitesh Kumar
 

More Related Content

What's hot

Setting UIAutomation free with Appium
Setting UIAutomation free with AppiumSetting UIAutomation free with Appium
Setting UIAutomation free with AppiumDan Cuellar
 
Setting Apple's UI Automation Free with Appium
Setting Apple's UI Automation Free with AppiumSetting Apple's UI Automation Free with Appium
Setting Apple's UI Automation Free with Appiummobiletestsummit
 
E2E testing Single Page Apps and APIs with Cucumber.js and Puppeteer
E2E testing Single Page Apps and APIs with Cucumber.js and PuppeteerE2E testing Single Page Apps and APIs with Cucumber.js and Puppeteer
E2E testing Single Page Apps and APIs with Cucumber.js and PuppeteerPaul Jensen
 
Hacking iOS Simulator: writing your own plugins for Simulator
Hacking iOS Simulator: writing your own plugins for SimulatorHacking iOS Simulator: writing your own plugins for Simulator
Hacking iOS Simulator: writing your own plugins for SimulatorAhmed Sulaiman
 
React Native: The Development Flow
React Native: The Development FlowReact Native: The Development Flow
React Native: The Development FlowRitesh Kumar
 
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...Paul Jensen
 
JAVA INTRODUCTION
JAVA INTRODUCTIONJAVA INTRODUCTION
JAVA INTRODUCTIONProf Ansari
 
Reactive Streams and RxJava2
Reactive Streams and RxJava2Reactive Streams and RxJava2
Reactive Streams and RxJava2Yakov Fain
 
C# Security Testing and Debugging
C# Security Testing and DebuggingC# Security Testing and Debugging
C# Security Testing and DebuggingRich Helton
 
iOS Parallel Automation: run faster than fast — Viktar Karanevich — SeleniumC...
iOS Parallel Automation: run faster than fast — Viktar Karanevich — SeleniumC...iOS Parallel Automation: run faster than fast — Viktar Karanevich — SeleniumC...
iOS Parallel Automation: run faster than fast — Viktar Karanevich — SeleniumC...Badoo
 
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)Ondřej Machulda
 
Seven Versions of One Web Application
Seven Versions of One Web ApplicationSeven Versions of One Web Application
Seven Versions of One Web ApplicationYakov Fain
 
iOS Parallel Automation - Viktar Karanevich - Mobile Test Automation Meetup (...
iOS Parallel Automation - Viktar Karanevich - Mobile Test Automation Meetup (...iOS Parallel Automation - Viktar Karanevich - Mobile Test Automation Meetup (...
iOS Parallel Automation - Viktar Karanevich - Mobile Test Automation Meetup (...Badoo
 
Scala for Test Automation
Scala for Test AutomationScala for Test Automation
Scala for Test Automationrthanavarapu
 
Apache ANT vs Apache Maven
Apache ANT vs Apache MavenApache ANT vs Apache Maven
Apache ANT vs Apache MavenMudit Gupta
 
Baruco 2014 - Rubymotion Workshop
Baruco 2014 - Rubymotion WorkshopBaruco 2014 - Rubymotion Workshop
Baruco 2014 - Rubymotion WorkshopBrian Sam-Bodden
 
JavaOne - The JavaFX Community and Ecosystem
JavaOne - The JavaFX Community and EcosystemJavaOne - The JavaFX Community and Ecosystem
JavaOne - The JavaFX Community and EcosystemAlexander Casall
 
Introduction to Groovy Monkey
Introduction to Groovy MonkeyIntroduction to Groovy Monkey
Introduction to Groovy Monkeyjervin
 
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...Ondřej Machulda
 

What's hot (20)

Setting UIAutomation free with Appium
Setting UIAutomation free with AppiumSetting UIAutomation free with Appium
Setting UIAutomation free with Appium
 
Setting Apple's UI Automation Free with Appium
Setting Apple's UI Automation Free with AppiumSetting Apple's UI Automation Free with Appium
Setting Apple's UI Automation Free with Appium
 
E2E testing Single Page Apps and APIs with Cucumber.js and Puppeteer
E2E testing Single Page Apps and APIs with Cucumber.js and PuppeteerE2E testing Single Page Apps and APIs with Cucumber.js and Puppeteer
E2E testing Single Page Apps and APIs with Cucumber.js and Puppeteer
 
Hacking iOS Simulator: writing your own plugins for Simulator
Hacking iOS Simulator: writing your own plugins for SimulatorHacking iOS Simulator: writing your own plugins for Simulator
Hacking iOS Simulator: writing your own plugins for Simulator
 
React Native: The Development Flow
React Native: The Development FlowReact Native: The Development Flow
React Native: The Development Flow
 
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
 
JAVA INTRODUCTION
JAVA INTRODUCTIONJAVA INTRODUCTION
JAVA INTRODUCTION
 
Reactive Streams and RxJava2
Reactive Streams and RxJava2Reactive Streams and RxJava2
Reactive Streams and RxJava2
 
C# Security Testing and Debugging
C# Security Testing and DebuggingC# Security Testing and Debugging
C# Security Testing and Debugging
 
iOS Parallel Automation: run faster than fast — Viktar Karanevich — SeleniumC...
iOS Parallel Automation: run faster than fast — Viktar Karanevich — SeleniumC...iOS Parallel Automation: run faster than fast — Viktar Karanevich — SeleniumC...
iOS Parallel Automation: run faster than fast — Viktar Karanevich — SeleniumC...
 
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
 
Seven Versions of One Web Application
Seven Versions of One Web ApplicationSeven Versions of One Web Application
Seven Versions of One Web Application
 
iOS Parallel Automation - Viktar Karanevich - Mobile Test Automation Meetup (...
iOS Parallel Automation - Viktar Karanevich - Mobile Test Automation Meetup (...iOS Parallel Automation - Viktar Karanevich - Mobile Test Automation Meetup (...
iOS Parallel Automation - Viktar Karanevich - Mobile Test Automation Meetup (...
 
Scala for Test Automation
Scala for Test AutomationScala for Test Automation
Scala for Test Automation
 
Apache ANT vs Apache Maven
Apache ANT vs Apache MavenApache ANT vs Apache Maven
Apache ANT vs Apache Maven
 
Baruco 2014 - Rubymotion Workshop
Baruco 2014 - Rubymotion WorkshopBaruco 2014 - Rubymotion Workshop
Baruco 2014 - Rubymotion Workshop
 
JavaOne - The JavaFX Community and Ecosystem
JavaOne - The JavaFX Community and EcosystemJavaOne - The JavaFX Community and Ecosystem
JavaOne - The JavaFX Community and Ecosystem
 
Introduction to Groovy Monkey
Introduction to Groovy MonkeyIntroduction to Groovy Monkey
Introduction to Groovy Monkey
 
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
 
Introduction to Apache Ant
Introduction to Apache AntIntroduction to Apache Ant
Introduction to Apache Ant
 

Viewers also liked

Javascript로 네이티브 iOS, Android앱 만들기 - Titanium
Javascript로 네이티브 iOS, Android앱 만들기 - TitaniumJavascript로 네이티브 iOS, Android앱 만들기 - Titanium
Javascript로 네이티브 iOS, Android앱 만들기 - TitaniumJongEun Lee
 
Titanium Mobile: flexibility vs. performance
Titanium Mobile: flexibility vs. performanceTitanium Mobile: flexibility vs. performance
Titanium Mobile: flexibility vs. performanceomorandi
 
10 Golden Rules For Outstanding Titanium Apps
 10 Golden Rules For Outstanding Titanium Apps 10 Golden Rules For Outstanding Titanium Apps
10 Golden Rules For Outstanding Titanium Appsjamessugrue
 
[Jscamp] Titanium - Javascript를 이용한 크로스 플랫폼 앱 개발
[Jscamp] Titanium - Javascript를 이용한 크로스 플랫폼 앱 개발[Jscamp] Titanium - Javascript를 이용한 크로스 플랫폼 앱 개발
[Jscamp] Titanium - Javascript를 이용한 크로스 플랫폼 앱 개발JongEun Lee
 
Titanium 소개 - 당신이 알고 있는 타이타늄 rev.201310
Titanium 소개 - 당신이 알고 있는 타이타늄 rev.201310Titanium 소개 - 당신이 알고 있는 타이타늄 rev.201310
Titanium 소개 - 당신이 알고 있는 타이타늄 rev.201310JongEun Lee
 
LAP2 iOS and Android Development environment setup
LAP2 iOS and Android Development environment setupLAP2 iOS and Android Development environment setup
LAP2 iOS and Android Development environment setupUniversity of Catania
 

Viewers also liked (6)

Javascript로 네이티브 iOS, Android앱 만들기 - Titanium
Javascript로 네이티브 iOS, Android앱 만들기 - TitaniumJavascript로 네이티브 iOS, Android앱 만들기 - Titanium
Javascript로 네이티브 iOS, Android앱 만들기 - Titanium
 
Titanium Mobile: flexibility vs. performance
Titanium Mobile: flexibility vs. performanceTitanium Mobile: flexibility vs. performance
Titanium Mobile: flexibility vs. performance
 
10 Golden Rules For Outstanding Titanium Apps
 10 Golden Rules For Outstanding Titanium Apps 10 Golden Rules For Outstanding Titanium Apps
10 Golden Rules For Outstanding Titanium Apps
 
[Jscamp] Titanium - Javascript를 이용한 크로스 플랫폼 앱 개발
[Jscamp] Titanium - Javascript를 이용한 크로스 플랫폼 앱 개발[Jscamp] Titanium - Javascript를 이용한 크로스 플랫폼 앱 개발
[Jscamp] Titanium - Javascript를 이용한 크로스 플랫폼 앱 개발
 
Titanium 소개 - 당신이 알고 있는 타이타늄 rev.201310
Titanium 소개 - 당신이 알고 있는 타이타늄 rev.201310Titanium 소개 - 당신이 알고 있는 타이타늄 rev.201310
Titanium 소개 - 당신이 알고 있는 타이타늄 rev.201310
 
LAP2 iOS and Android Development environment setup
LAP2 iOS and Android Development environment setupLAP2 iOS and Android Development environment setup
LAP2 iOS and Android Development environment setup
 

Similar to Titanium - Making the most of your single thread

Building Hermetic Systems (without Docker)
Building Hermetic Systems (without Docker)Building Hermetic Systems (without Docker)
Building Hermetic Systems (without Docker)William Farrell
 
Development Of A Simulation Management System
Development Of A Simulation Management SystemDevelopment Of A Simulation Management System
Development Of A Simulation Management SystemHeather Vargas
 
Realtime selenium interview questions
Realtime selenium interview questionsRealtime selenium interview questions
Realtime selenium interview questionsKuldeep Pawar
 
Building scalable applications with angular js
Building scalable applications with angular jsBuilding scalable applications with angular js
Building scalable applications with angular jsAndrew Alpert
 
Debugging Complex Systems - Erlang Factory SF 2015
Debugging Complex Systems - Erlang Factory SF 2015Debugging Complex Systems - Erlang Factory SF 2015
Debugging Complex Systems - Erlang Factory SF 2015lpgauth
 
Stateful patterns in Azure Functions
Stateful patterns in Azure FunctionsStateful patterns in Azure Functions
Stateful patterns in Azure FunctionsMassimo Bonanni
 
How and what to unit test
How and what to unit testHow and what to unit test
How and what to unit testEugenio Lentini
 
Java script unit testing
Java script unit testingJava script unit testing
Java script unit testingMats Bryntse
 
Develop in ludicrous mode with azure serverless
Develop in ludicrous mode with azure serverlessDevelop in ludicrous mode with azure serverless
Develop in ludicrous mode with azure serverlessLalit Kale
 
Testing Ext JS and Sencha Touch
Testing Ext JS and Sencha TouchTesting Ext JS and Sencha Touch
Testing Ext JS and Sencha TouchMats Bryntse
 
Troubleshooting: The Two Laws - IXIASOFT User Conference 2016
Troubleshooting: The Two Laws - IXIASOFT User Conference 2016Troubleshooting: The Two Laws - IXIASOFT User Conference 2016
Troubleshooting: The Two Laws - IXIASOFT User Conference 2016IXIASOFT
 
High Performance JavaScript (CapitolJS 2011)
High Performance JavaScript (CapitolJS 2011)High Performance JavaScript (CapitolJS 2011)
High Performance JavaScript (CapitolJS 2011)Nicholas Zakas
 
PART-3 : Mastering RTOS FreeRTOS and STM32Fx with Debugging
PART-3 : Mastering RTOS FreeRTOS and STM32Fx with DebuggingPART-3 : Mastering RTOS FreeRTOS and STM32Fx with Debugging
PART-3 : Mastering RTOS FreeRTOS and STM32Fx with DebuggingFastBit Embedded Brain Academy
 
Defcon 22-paul-mcmillan-attacking-the-iot-using-timing-attac
Defcon 22-paul-mcmillan-attacking-the-iot-using-timing-attacDefcon 22-paul-mcmillan-attacking-the-iot-using-timing-attac
Defcon 22-paul-mcmillan-attacking-the-iot-using-timing-attacPriyanka Aash
 
[Java concurrency]01.thread management
[Java concurrency]01.thread management[Java concurrency]01.thread management
[Java concurrency]01.thread managementxuehan zhu
 
Beyond the RTOS: A Better Way to Design Real-Time Embedded Software
Beyond the RTOS: A Better Way to Design Real-Time Embedded SoftwareBeyond the RTOS: A Better Way to Design Real-Time Embedded Software
Beyond the RTOS: A Better Way to Design Real-Time Embedded SoftwareQuantum Leaps, LLC
 

Similar to Titanium - Making the most of your single thread (20)

Building Hermetic Systems (without Docker)
Building Hermetic Systems (without Docker)Building Hermetic Systems (without Docker)
Building Hermetic Systems (without Docker)
 
Development Of A Simulation Management System
Development Of A Simulation Management SystemDevelopment Of A Simulation Management System
Development Of A Simulation Management System
 
Java multi thread programming on cmp system
Java multi thread programming on cmp systemJava multi thread programming on cmp system
Java multi thread programming on cmp system
 
Why test with flex unit
Why test with flex unitWhy test with flex unit
Why test with flex unit
 
Realtime selenium interview questions
Realtime selenium interview questionsRealtime selenium interview questions
Realtime selenium interview questions
 
Building scalable applications with angular js
Building scalable applications with angular jsBuilding scalable applications with angular js
Building scalable applications with angular js
 
Debugging Complex Systems - Erlang Factory SF 2015
Debugging Complex Systems - Erlang Factory SF 2015Debugging Complex Systems - Erlang Factory SF 2015
Debugging Complex Systems - Erlang Factory SF 2015
 
Stateful patterns in Azure Functions
Stateful patterns in Azure FunctionsStateful patterns in Azure Functions
Stateful patterns in Azure Functions
 
How and what to unit test
How and what to unit testHow and what to unit test
How and what to unit test
 
Java script unit testing
Java script unit testingJava script unit testing
Java script unit testing
 
Develop in ludicrous mode with azure serverless
Develop in ludicrous mode with azure serverlessDevelop in ludicrous mode with azure serverless
Develop in ludicrous mode with azure serverless
 
Devignition 2011
Devignition 2011Devignition 2011
Devignition 2011
 
Testing Ext JS and Sencha Touch
Testing Ext JS and Sencha TouchTesting Ext JS and Sencha Touch
Testing Ext JS and Sencha Touch
 
Troubleshooting: The Two Laws - IXIASOFT User Conference 2016
Troubleshooting: The Two Laws - IXIASOFT User Conference 2016Troubleshooting: The Two Laws - IXIASOFT User Conference 2016
Troubleshooting: The Two Laws - IXIASOFT User Conference 2016
 
Conf orm - explain
Conf orm - explainConf orm - explain
Conf orm - explain
 
High Performance JavaScript (CapitolJS 2011)
High Performance JavaScript (CapitolJS 2011)High Performance JavaScript (CapitolJS 2011)
High Performance JavaScript (CapitolJS 2011)
 
PART-3 : Mastering RTOS FreeRTOS and STM32Fx with Debugging
PART-3 : Mastering RTOS FreeRTOS and STM32Fx with DebuggingPART-3 : Mastering RTOS FreeRTOS and STM32Fx with Debugging
PART-3 : Mastering RTOS FreeRTOS and STM32Fx with Debugging
 
Defcon 22-paul-mcmillan-attacking-the-iot-using-timing-attac
Defcon 22-paul-mcmillan-attacking-the-iot-using-timing-attacDefcon 22-paul-mcmillan-attacking-the-iot-using-timing-attac
Defcon 22-paul-mcmillan-attacking-the-iot-using-timing-attac
 
[Java concurrency]01.thread management
[Java concurrency]01.thread management[Java concurrency]01.thread management
[Java concurrency]01.thread management
 
Beyond the RTOS: A Better Way to Design Real-Time Embedded Software
Beyond the RTOS: A Better Way to Design Real-Time Embedded SoftwareBeyond the RTOS: A Better Way to Design Real-Time Embedded Software
Beyond the RTOS: A Better Way to Design Real-Time Embedded Software
 

Recently uploaded

human behaviour and personality development ppt.pptx
human behaviour and personality development ppt.pptxhuman behaviour and personality development ppt.pptx
human behaviour and personality development ppt.pptxpoonambiswas4
 
CONCEPTS OF ENVIRONMENT & ECOSYSTEM.pptx
CONCEPTS OF ENVIRONMENT & ECOSYSTEM.pptxCONCEPTS OF ENVIRONMENT & ECOSYSTEM.pptx
CONCEPTS OF ENVIRONMENT & ECOSYSTEM.pptxAnupkumar Sharma
 
Introduction of General Pharmacology PPT.pptx
Introduction of General Pharmacology PPT.pptxIntroduction of General Pharmacology PPT.pptx
Introduction of General Pharmacology PPT.pptxRenuka N Sunagad
 
2.15.24 The Birmingham Campaign and MLK.pptx
2.15.24 The Birmingham Campaign and MLK.pptx2.15.24 The Birmingham Campaign and MLK.pptx
2.15.24 The Birmingham Campaign and MLK.pptxMaryPotorti1
 
mean stack mean stack mean stack mean stack
mean stack mean stack  mean stack  mean stackmean stack mean stack  mean stack  mean stack
mean stack mean stack mean stack mean stackNuttavutThongjor1
 
Media Relations for Public Relations Class
Media Relations for Public Relations ClassMedia Relations for Public Relations Class
Media Relations for Public Relations ClassCorinne Weisgerber
 
2023 MAP Data Analysis - St. Louis Region
2023 MAP Data Analysis - St. Louis Region2023 MAP Data Analysis - St. Louis Region
2023 MAP Data Analysis - St. Louis RegionThe Opportunity Trust
 
John See - Narrative Story
John See - Narrative StoryJohn See - Narrative Story
John See - Narrative StoryAlan See
 
Writing Agony Letter & If type O+1 & Diphthongs + Text “Arab Science”.pdf
Writing Agony Letter & If type O+1 & Diphthongs + Text “Arab Science”.pdfWriting Agony Letter & If type O+1 & Diphthongs + Text “Arab Science”.pdf
Writing Agony Letter & If type O+1 & Diphthongs + Text “Arab Science”.pdfMr Bounab Samir
 
Intuition behind Monte Carlo Markov Chains
Intuition behind Monte Carlo Markov ChainsIntuition behind Monte Carlo Markov Chains
Intuition behind Monte Carlo Markov ChainsTushar Tank
 
Bayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with ExamplesBayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with ExamplesTushar Tank
 
Sudden Death of Beliefs
Sudden Death of BeliefsSudden Death of Beliefs
Sudden Death of BeliefsRay Poynter
 
Unleashing the Power of AI Tools for Enhancing Research, International FDP on...
Unleashing the Power of AI Tools for Enhancing Research, International FDP on...Unleashing the Power of AI Tools for Enhancing Research, International FDP on...
Unleashing the Power of AI Tools for Enhancing Research, International FDP on...Dr. Vinod Kumar Kanvaria
 
50 ĐỀ THI THỬ TỐT NGHIỆP THPT TIẾNG ANH 2024 CÓ GIẢI CHI TIẾT - GIỚI HẠN KHO...
50 ĐỀ THI THỬ TỐT NGHIỆP THPT TIẾNG ANH 2024 CÓ GIẢI CHI TIẾT - GIỚI HẠN KHO...50 ĐỀ THI THỬ TỐT NGHIỆP THPT TIẾNG ANH 2024 CÓ GIẢI CHI TIẾT - GIỚI HẠN KHO...
50 ĐỀ THI THỬ TỐT NGHIỆP THPT TIẾNG ANH 2024 CÓ GIẢI CHI TIẾT - GIỚI HẠN KHO...Nguyen Thanh Tu Collection
 
Blue Persuasive Writing English Essay Worksheet (1).pdf
Blue Persuasive Writing English Essay Worksheet (1).pdfBlue Persuasive Writing English Essay Worksheet (1).pdf
Blue Persuasive Writing English Essay Worksheet (1).pdfAngelaAmparado
 
UG - Water Disinfection.pptx
UG - Water Disinfection.pptxUG - Water Disinfection.pptx
UG - Water Disinfection.pptxMelbinRockieMJ1
 
“ Seed and Fruit development and Seed and Fruit Abortion ”.pptx
“ Seed and Fruit development and Seed and Fruit Abortion ”.pptx“ Seed and Fruit development and Seed and Fruit Abortion ”.pptx
“ Seed and Fruit development and Seed and Fruit Abortion ”.pptxAKSHAYMAGAR17
 
LIPIDS UNIT ONE BIOMOLECULE PRESENTATION
LIPIDS UNIT ONE BIOMOLECULE PRESENTATIONLIPIDS UNIT ONE BIOMOLECULE PRESENTATION
LIPIDS UNIT ONE BIOMOLECULE PRESENTATIONSayali Powar
 
Digital Storytelling Community Launch!.pptx
Digital Storytelling Community Launch!.pptxDigital Storytelling Community Launch!.pptx
Digital Storytelling Community Launch!.pptxJisc
 
Depiction of Mythology in Western and Bollywood cinemas.pptx
Depiction of Mythology in Western and Bollywood cinemas.pptxDepiction of Mythology in Western and Bollywood cinemas.pptx
Depiction of Mythology in Western and Bollywood cinemas.pptxDrashtiJoshi21
 

Recently uploaded (20)

human behaviour and personality development ppt.pptx
human behaviour and personality development ppt.pptxhuman behaviour and personality development ppt.pptx
human behaviour and personality development ppt.pptx
 
CONCEPTS OF ENVIRONMENT & ECOSYSTEM.pptx
CONCEPTS OF ENVIRONMENT & ECOSYSTEM.pptxCONCEPTS OF ENVIRONMENT & ECOSYSTEM.pptx
CONCEPTS OF ENVIRONMENT & ECOSYSTEM.pptx
 
Introduction of General Pharmacology PPT.pptx
Introduction of General Pharmacology PPT.pptxIntroduction of General Pharmacology PPT.pptx
Introduction of General Pharmacology PPT.pptx
 
2.15.24 The Birmingham Campaign and MLK.pptx
2.15.24 The Birmingham Campaign and MLK.pptx2.15.24 The Birmingham Campaign and MLK.pptx
2.15.24 The Birmingham Campaign and MLK.pptx
 
mean stack mean stack mean stack mean stack
mean stack mean stack  mean stack  mean stackmean stack mean stack  mean stack  mean stack
mean stack mean stack mean stack mean stack
 
Media Relations for Public Relations Class
Media Relations for Public Relations ClassMedia Relations for Public Relations Class
Media Relations for Public Relations Class
 
2023 MAP Data Analysis - St. Louis Region
2023 MAP Data Analysis - St. Louis Region2023 MAP Data Analysis - St. Louis Region
2023 MAP Data Analysis - St. Louis Region
 
John See - Narrative Story
John See - Narrative StoryJohn See - Narrative Story
John See - Narrative Story
 
Writing Agony Letter & If type O+1 & Diphthongs + Text “Arab Science”.pdf
Writing Agony Letter & If type O+1 & Diphthongs + Text “Arab Science”.pdfWriting Agony Letter & If type O+1 & Diphthongs + Text “Arab Science”.pdf
Writing Agony Letter & If type O+1 & Diphthongs + Text “Arab Science”.pdf
 
Intuition behind Monte Carlo Markov Chains
Intuition behind Monte Carlo Markov ChainsIntuition behind Monte Carlo Markov Chains
Intuition behind Monte Carlo Markov Chains
 
Bayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with ExamplesBayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with Examples
 
Sudden Death of Beliefs
Sudden Death of BeliefsSudden Death of Beliefs
Sudden Death of Beliefs
 
Unleashing the Power of AI Tools for Enhancing Research, International FDP on...
Unleashing the Power of AI Tools for Enhancing Research, International FDP on...Unleashing the Power of AI Tools for Enhancing Research, International FDP on...
Unleashing the Power of AI Tools for Enhancing Research, International FDP on...
 
50 ĐỀ THI THỬ TỐT NGHIỆP THPT TIẾNG ANH 2024 CÓ GIẢI CHI TIẾT - GIỚI HẠN KHO...
50 ĐỀ THI THỬ TỐT NGHIỆP THPT TIẾNG ANH 2024 CÓ GIẢI CHI TIẾT - GIỚI HẠN KHO...50 ĐỀ THI THỬ TỐT NGHIỆP THPT TIẾNG ANH 2024 CÓ GIẢI CHI TIẾT - GIỚI HẠN KHO...
50 ĐỀ THI THỬ TỐT NGHIỆP THPT TIẾNG ANH 2024 CÓ GIẢI CHI TIẾT - GIỚI HẠN KHO...
 
Blue Persuasive Writing English Essay Worksheet (1).pdf
Blue Persuasive Writing English Essay Worksheet (1).pdfBlue Persuasive Writing English Essay Worksheet (1).pdf
Blue Persuasive Writing English Essay Worksheet (1).pdf
 
UG - Water Disinfection.pptx
UG - Water Disinfection.pptxUG - Water Disinfection.pptx
UG - Water Disinfection.pptx
 
“ Seed and Fruit development and Seed and Fruit Abortion ”.pptx
“ Seed and Fruit development and Seed and Fruit Abortion ”.pptx“ Seed and Fruit development and Seed and Fruit Abortion ”.pptx
“ Seed and Fruit development and Seed and Fruit Abortion ”.pptx
 
LIPIDS UNIT ONE BIOMOLECULE PRESENTATION
LIPIDS UNIT ONE BIOMOLECULE PRESENTATIONLIPIDS UNIT ONE BIOMOLECULE PRESENTATION
LIPIDS UNIT ONE BIOMOLECULE PRESENTATION
 
Digital Storytelling Community Launch!.pptx
Digital Storytelling Community Launch!.pptxDigital Storytelling Community Launch!.pptx
Digital Storytelling Community Launch!.pptx
 
Depiction of Mythology in Western and Bollywood cinemas.pptx
Depiction of Mythology in Western and Bollywood cinemas.pptxDepiction of Mythology in Western and Bollywood cinemas.pptx
Depiction of Mythology in Western and Bollywood cinemas.pptx
 

Titanium - Making the most of your single thread

  • 1. Making the most of your single thread Titanium - Fundamentals
  • 2. Congrats! ! Your app is in the hands of the public! Your users click on buttons, open windows, and at some point someone touches a button that results in…
  • 3. Absolutely Nothing. He tries touching it three times, before deciding, after a mere few seconds, that your app has crashed. ! He kills your app.
  • 4. Had he waited for ‘but’ 5 seconds.. .. he would have noticed three windows opening in rapid succession. Three identical windows, as he would observe when using the ‘back’-button.
  • 5. What did you do wrong? • There’s no loading indicator showing • There is no mechanic in place to prevent additional windows from opening
  • 6. What did you do wrong? • There’s no loading indicator showing • There is no mechanic in place to prevent additional windows from opening • But more important: You blocked the UI far too long! You did not make the best use of your single thread!
  • 7. Ronald Treur Co-founder Snowciety ! Freelance developer ! 2.5 yrs Titanium experience ! @ronaldtreur ronald@funcracker.net
  • 8. Making the Most of Your Single Thread • Threads & Threading • How it works in Native & Titanium • Javascript call stack example • Underscore - Defer
  • 9. Thread The smallest subset of a process that could be independently handled by the OS. or The smallest piece of code, that could be executed independently from the rest of the code.
  • 11. Threading • Multi-threaded: 
 - Threads (can) run in parallel, meaning:
 - Multiple pieces of code can execute at the same time. #1 #2 ! #3 #4 ! • #1 Single-threaded:
 - Threads can only run serially, meaning:
 - Only one piece of code can execute at a time. #2 #3
  • 14. How your app works JS Thread #1
  • 15. Thread Safe Javascript is by definition NOT thread safe. • If multiple threads would be able to access and change the same object/variable, a race condition might occur. • aka: the outcome of a piece of code would be unpredictable.
  • 16. Single Threaded Javascript is by definition NOT thread safe. Thus it is, by nature, single threaded. • Timers are not part of Javascript, they are part of the JS engine (Rhino, V8, JavaScriptCore) • Timers allow for asynchronous delays, but code execution remains single threaded. • When a timer expires, or an event fires, the resulting execution is queued.
  • 18. Call Stack ms ‘events’ 0 0 0 foo() setInterval(bar, 10) setTimeout(nerf, 20) nerf() foo() bar() bar() bar() bar() bar() 30 40 50 foo() 0 10 20 ms
  • 19. Call Stack [click] foo() ‘events’ 0 0 0 6 foo() setInterval(bar, 10) setTimeout(nerf, 20) Button clicked nerf() bar() foo() 0 ms 10 bar() bar() bar() bar() 30 40 50 click handler 20 ms
  • 20. Call Stack ms In Titanium the queue is FIFO (first in, first out). [click] foo() 0 0 0 6 10 foo() setInterval(bar, 10) setTimeout(nerf, 20) Button clicked Interval fires nerf() bar() foo() 0 ‘events’ 10 bar() bar() bar() bar() 40 50 click bar() handler 20 ms 30
  • 21. Call Stack [click] foo() ‘events’ 0 0 0 6 10 20 foo() setInterval(bar, 10) setTimeout(nerf, 20) Button clicked Interval fires Interval & Timer fire nerf() bar() foo() 0 ms 10 bar() bar() bar() bar() click bar() nerf() handler 20 ms 30 40 50
  • 22. Call Stack ms The interval at 20ms is ignored, an execution is already scheduled. [click] foo() 0 0 0 6 10 20 foo() setInterval(bar, 10) setTimeout(nerf, 20) Button clicked Interval fires Interval & Timer fire nerf() bar() foo() 0 ‘events’ 10 bar() bar() bar() bar() click bar() nerf() handler 20 ms 30 40 50
  • 23. Call Stack ms The interval at 30ms is queued, since no execution is scheduled. [click] foo() 0 0 0 6 10 20 30 foo() setInterval(bar, 10) setTimeout(nerf, 20) Button clicked Interval fires Interval & Timer fire Interval fires nerf() bar() foo() 0 ‘events’ 10 bar() bar() bar() bar() click bar() nerf() bar() handler 20 ms 30 40 50
  • 24. Call Stack ms ‘events’ nerf() 0 0 0 6 10 20 30 40 foo() setInterval(bar, 10) setTimeout(nerf, 20) Button clicked Interval fires Interval & Timer fire Interval fires Interval fires bar() bar() Interval at 40ms is ignored. [click] foo() bar() foo() 0 10 bar() bar() click bar() nerf() bar() handler 20 ms 30 40 50
  • 25. Call Stack ms Interval at 50ms is the first to execute at the correct time (though 2 executions were dropped). [click] foo() nerf() bar() foo() 0 10 bar() ‘events’ 0 0 0 6 10 20 30 40 50 foo() setInterval(bar, 10) setTimeout(nerf, 20) Button clicked Interval fires Interval & Timer fire Interval fires Interval fires Interval fires bar() bar() click bar() nerf() bar() handler 20 ms 30 40 bar() bar() 50
  • 26. Conclusions • If code is already executing, events and timers are queued • Timers may not execute exactly when you were expecting • Intervals may not fire as often as you were expecting • User interaction is queued as well, which the user interprets as the UI being unresponsive.
  • 27. setTimeout vs setInterval setTimeout ( function nerf() { ….. setTimeout ( nerf, 10); }, 10); -VSsetInterval ( function() { ….. }, 10);
  • 28. Underscore - Defer _.defer(function, [*arguments]) Defers invoking the function until the current call stack has cleared, similar to using setTimeout with a delay of 0. Useful for performing expensive computations or HTML rendering in chunks without blocking the UI thread from updating. If you pass the optional arguments, they will be forwarded on to the function when it is invoked. ! _.defer ( function() { alert(‘deferred’); }); ! // Returns from the function before the alert runs.
  • 31. Conclusions • Try to keep the User experience as responsive as possible. Use _.defer! • Always show loading-indicators when you can’t. • Limit the amount of actions everywhere in your app. For example: Widgitize your button and/or use _.throttle.
  • 32. Underscore - Throttle _.throttle(function, wait, [options]) Creates and returns a new, throttled version of the passed function, that, when invoked repeatedly, will only actually call the original function at most once per every wait milliseconds. Useful for ratelimiting events that occur faster than you can keep up with. var throttled = _.throttle ( updatePosition, 100); $(window).scroll(throttled);