The document discusses modern Java concurrency. It introduces the topic and explains why developers may want to utilize modern Java concurrency features. It discusses the java.util.concurrent library and how it provides building blocks for concurrent and thread-safe code like ReentrantLock, Condition, ConcurrentHashMap. It provides examples of using constructs like CountDownLatch, ThreadPoolExecutor, ForkJoin to write concurrent applications in a safer and more performant way compared to traditional locking approaches.
Part 1/3 of our Devoxx University session. An introduction to some of the features of Java 7!
We're still working out where to host the torrent of our Virtual Box image with the coding exercises, we'll update the description when we sort it out.
Paperwork, Politics and Pain - Our year in the JCP (FOSDEM 2012)Martijn Verburg
In 2011 the London Java Community (LJC) stood for, and overwhelmingly won a seat in the open elections for a seat on the JCP Executive Committee (JCP EC), enough acronyms yet? We haven't even started! It's been a whirlwind trip so far with a great deal learned about politics, acronyms, the due diligence required on a JSR, flights to exotic places (Jersey City!?), wrangling over the wording of a sentence and of course launching some developer lead initiatives.
There have of course been some great successes in moving Free Java forward such as the JSR-348 which is the start of reforming the JCP and JSRs towards a truly open and transparent model. This talk covers the good works done so far, some anecdotes of what it's like to work as a developer amongst a mix of technologists and techies and what we think is left to be done.
You spend your precious time building the perfect application. You do everything right. You carefully craft every piece of code and rigorously follow the best practices and design patterns, you apply the most successful methodologies software engineering has to offer with discipline, and you pay attention to the most minuscule of details to produce the best user experience possible. It all pays off eventually, and you end up with a beautiful code base that is not only reliable but also performs well. You proudly watch your baby grow, as new users come in bringing more traffic your way and craving new features. You keep them happy and they keep coming back. One morning, you wake up to servers crashing under load, and data stores failing to keep up with all the demand. You panic. You throw in more hardware and try optimize, but the hungry crowd that was once your happy user base catches up to you. Your success is slipping through your fingers. You find yourself stuck between having to rewrite the whole application and a hard place. It's frustrating, dreadful, and painful to say the least. Don't be that guy! Save your soul before it's too late, and come to learn how to build, deploy, and maintain enterprise-grade Java applications that scale from day one. Topics covered include: parallelism, load distribution, state management, caching, big data, asynchronous processing, and static content delivery. Leveraging cloud computing, scaling teams and DevOps will also be discuss. P.S. This session is more technical than you might think.
http://jaxconf.com/sessions/economies-scaling-software
In this session you will learn:
Understand the advantages of Java
Understand where Java is used
Understand how memory management is handled in Java
Create a Java project in Eclipse and execute it
Implement if..else construct in Java
Develop codes using various data types in Java
Implement various loops
For more information: https://www.mindsmapped.com/courses/software-development/become-a-java-developer-hands-on-training/
In this session you will learn:
Introduction to Java
History of Java
Salient Features of Java
Setting up Environment for Java development
Object Oriented Programming Concepts
For more information: https://www.mindsmapped.com/courses/software-development/become-a-java-developer-hands-on-training/
Once upon a time in the C++ century, the Great King of Sun said people need Duke, The PDA (a medieval version of a tablet). He picked his bravest knights – Naughton, Sheriden and Gosling – and entrusted them a secret mission to travel the universe in search for a perfect language that Duke can use.
After three years of a dangerous journey in a world of bits, bytes and memory leakages, on an Asian isle they found it. Java made of Oak has been discovered.
When they returned the King was not in power anymore. New world was ruled by a mysterious organisation, World Wide Web. Our brave knights honoured it with the glorious Java. And the world became perfect…
Mani and Rafal will take your through an exciting story of great programmers, multi-billion company wars, and - most importantly – language features. The history of Java, from its inception till just about today.
The State of Managed Runtimes 2013, by Attila SzegediZeroTurnaround
There’s JVM, and that’s it, right? Well, not exactly. Even within JVM, there’s an increasing support for running all kinds of non-Java languages: we have invokedynamic, but it’s being improved, and new layers of functionality are emerging on top of it, making JVM a better home for all kinds of programming languages. There’s life outside of JVM too. JavaScript seems to be a new assembler-lever compilation target even for C programs (I’ll show some amusing examples of what exactly you can run these days in a browser) , and there are some independent efforts at managed runtimes in various stages of completion that seem promising – PyPy, Topaz, Rubinius, Parrot VM (it’s alive again!). This talk is admittedly a language-runtime-enthusiast’s walk-through the things he finds interesting happening this year. Recorded at GeekOut 2013.
Kitware is involved with Qt in two main areas. First, Kitware is the provider of the CMake (www.cmake.org) build tool which is used to build KDE, the flagship open source Qt project. In addition, Kitware has been using Qt for the ParaView (www.paraview.org) project. ParaView is an open-source, multi-platform data analysis and visualization application. With the recent change in Qt licensing Kitware is also starting to use Qt for many other open source scientific and medical projects. For cross platform C++ GUI development Qt now stands alone as really the only viable choice. This talk will cover the CMake build system, and the impact Qt and Qt derived projects are having on state of the art scientific computation.
Presentation by BIll Hoffman held during Qt Developer Days 2009.
http://qt.nokia.com/developer/learning/elearning
Go - A Key Language in Enterprise Application Development?C4Media
Video and slides synchronized, mp3 and slide download available at URL https://bit.ly/2COBbRN.
Aarti Parikh goes over the Go language design and talks about why Go matters in the age of multicores and cloud-native computing. Filmed at qconsf.com.
Aarti Parikh is a software engineering manager with a decade of experience building teams and products for the Internet, IoT and now Fintech. Currently, she works at PayPal.
Part 1/3 of our Devoxx University session. An introduction to some of the features of Java 7!
We're still working out where to host the torrent of our Virtual Box image with the coding exercises, we'll update the description when we sort it out.
Paperwork, Politics and Pain - Our year in the JCP (FOSDEM 2012)Martijn Verburg
In 2011 the London Java Community (LJC) stood for, and overwhelmingly won a seat in the open elections for a seat on the JCP Executive Committee (JCP EC), enough acronyms yet? We haven't even started! It's been a whirlwind trip so far with a great deal learned about politics, acronyms, the due diligence required on a JSR, flights to exotic places (Jersey City!?), wrangling over the wording of a sentence and of course launching some developer lead initiatives.
There have of course been some great successes in moving Free Java forward such as the JSR-348 which is the start of reforming the JCP and JSRs towards a truly open and transparent model. This talk covers the good works done so far, some anecdotes of what it's like to work as a developer amongst a mix of technologists and techies and what we think is left to be done.
You spend your precious time building the perfect application. You do everything right. You carefully craft every piece of code and rigorously follow the best practices and design patterns, you apply the most successful methodologies software engineering has to offer with discipline, and you pay attention to the most minuscule of details to produce the best user experience possible. It all pays off eventually, and you end up with a beautiful code base that is not only reliable but also performs well. You proudly watch your baby grow, as new users come in bringing more traffic your way and craving new features. You keep them happy and they keep coming back. One morning, you wake up to servers crashing under load, and data stores failing to keep up with all the demand. You panic. You throw in more hardware and try optimize, but the hungry crowd that was once your happy user base catches up to you. Your success is slipping through your fingers. You find yourself stuck between having to rewrite the whole application and a hard place. It's frustrating, dreadful, and painful to say the least. Don't be that guy! Save your soul before it's too late, and come to learn how to build, deploy, and maintain enterprise-grade Java applications that scale from day one. Topics covered include: parallelism, load distribution, state management, caching, big data, asynchronous processing, and static content delivery. Leveraging cloud computing, scaling teams and DevOps will also be discuss. P.S. This session is more technical than you might think.
http://jaxconf.com/sessions/economies-scaling-software
In this session you will learn:
Understand the advantages of Java
Understand where Java is used
Understand how memory management is handled in Java
Create a Java project in Eclipse and execute it
Implement if..else construct in Java
Develop codes using various data types in Java
Implement various loops
For more information: https://www.mindsmapped.com/courses/software-development/become-a-java-developer-hands-on-training/
In this session you will learn:
Introduction to Java
History of Java
Salient Features of Java
Setting up Environment for Java development
Object Oriented Programming Concepts
For more information: https://www.mindsmapped.com/courses/software-development/become-a-java-developer-hands-on-training/
Once upon a time in the C++ century, the Great King of Sun said people need Duke, The PDA (a medieval version of a tablet). He picked his bravest knights – Naughton, Sheriden and Gosling – and entrusted them a secret mission to travel the universe in search for a perfect language that Duke can use.
After three years of a dangerous journey in a world of bits, bytes and memory leakages, on an Asian isle they found it. Java made of Oak has been discovered.
When they returned the King was not in power anymore. New world was ruled by a mysterious organisation, World Wide Web. Our brave knights honoured it with the glorious Java. And the world became perfect…
Mani and Rafal will take your through an exciting story of great programmers, multi-billion company wars, and - most importantly – language features. The history of Java, from its inception till just about today.
The State of Managed Runtimes 2013, by Attila SzegediZeroTurnaround
There’s JVM, and that’s it, right? Well, not exactly. Even within JVM, there’s an increasing support for running all kinds of non-Java languages: we have invokedynamic, but it’s being improved, and new layers of functionality are emerging on top of it, making JVM a better home for all kinds of programming languages. There’s life outside of JVM too. JavaScript seems to be a new assembler-lever compilation target even for C programs (I’ll show some amusing examples of what exactly you can run these days in a browser) , and there are some independent efforts at managed runtimes in various stages of completion that seem promising – PyPy, Topaz, Rubinius, Parrot VM (it’s alive again!). This talk is admittedly a language-runtime-enthusiast’s walk-through the things he finds interesting happening this year. Recorded at GeekOut 2013.
Kitware is involved with Qt in two main areas. First, Kitware is the provider of the CMake (www.cmake.org) build tool which is used to build KDE, the flagship open source Qt project. In addition, Kitware has been using Qt for the ParaView (www.paraview.org) project. ParaView is an open-source, multi-platform data analysis and visualization application. With the recent change in Qt licensing Kitware is also starting to use Qt for many other open source scientific and medical projects. For cross platform C++ GUI development Qt now stands alone as really the only viable choice. This talk will cover the CMake build system, and the impact Qt and Qt derived projects are having on state of the art scientific computation.
Presentation by BIll Hoffman held during Qt Developer Days 2009.
http://qt.nokia.com/developer/learning/elearning
Go - A Key Language in Enterprise Application Development?C4Media
Video and slides synchronized, mp3 and slide download available at URL https://bit.ly/2COBbRN.
Aarti Parikh goes over the Go language design and talks about why Go matters in the age of multicores and cloud-native computing. Filmed at qconsf.com.
Aarti Parikh is a software engineering manager with a decade of experience building teams and products for the Internet, IoT and now Fintech. Currently, she works at PayPal.
Concurrency and Multithreading Demistified - Reversim Summit 2014Haim Yadid
Life as a software engineer is so exciting! Computing power continue to rise exponentially, software demands continue to rise exponentially as well, so far so good. The bad news are that in the last decade the computing power of single threaded application remains almost flat.
If you decide to continue ignoring concurrency and multi-threading the gap between the problems you are able to solve and your hardware capabilities will continue to rise. In this session we will discuss different approaches for taming the concurrency beast, such as shared mutability,shared immutability and isolated mutability actors, STM, etc we will discuss the shortcomings and the dangers of each approach and we will compare different programming languages and how they choose to tackle/ignore concurrency.
Slides from talk given on Java/Scala Lab 2014 in Odessa, Ukraine. Describes of how Java can be used as platform for latency-restricted applications such as High Frequency Trading and demonstrates how latencies 15-30µsec can be achieved on vanilla Oracle JDK.
Java 9 is just around the corner. In this session, we'll describe the new modularization support (Jigsaw), new JDK tools, enhanced APIs and many performance improvements that were added to the new version.
A set of slides on the basics of concurrency touching upon Java's support for multi-threaded programming, do's and dont's, common approaches to developing concurrent applications and evolution of APIs in Java that support effective multi-threaded programming
Writing concurrent programs that can run in multiple threads and on multiple cores is crucial but daunting. Futures provides a convenient abstraction for many problem domains. The online course "Intermediate Scala" includes an up-to-date discussion of futures and the parts of java.util.concurrent that underlie the Scala futures implementation. Unlike Java's futures, Scala futures supports composition, transformations and sophisticated callbacks.
The author is managing editor of http://scalacourses.com, which offers self-paced online courses that teach Introductory and Intermediate Scala and Play Framework.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
Welcome to the first live UiPath Community Day Dubai! Join us for this unique occasion to meet our local and global UiPath Community and leaders. You will get a full view of the MEA region's automation landscape and the AI Powered automation technology capabilities of UiPath. Also, hosted by our local partners Marc Ellis, you will enjoy a half-day packed with industry insights and automation peers networking.
📕 Curious on our agenda? Wait no more!
10:00 Welcome note - UiPath Community in Dubai
Lovely Sinha, UiPath Community Chapter Leader, UiPath MVPx3, Hyper-automation Consultant, First Abu Dhabi Bank
10:20 A UiPath cross-region MEA overview
Ashraf El Zarka, VP and Managing Director MEA, UiPath
10:35: Customer Success Journey
Deepthi Deepak, Head of Intelligent Automation CoE, First Abu Dhabi Bank
11:15 The UiPath approach to GenAI with our three principles: improve accuracy, supercharge productivity, and automate more
Boris Krumrey, Global VP, Automation Innovation, UiPath
12:15 To discover how Marc Ellis leverages tech-driven solutions in recruitment and managed services.
Brendan Lingam, Director of Sales and Business Development, Marc Ellis
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
A tale of scale & speed: How the US Navy is enabling software delivery from l...sonjaschweigert1
Rapid and secure feature delivery is a goal across every application team and every branch of the DoD. The Navy’s DevSecOps platform, Party Barge, has achieved:
- Reduction in onboarding time from 5 weeks to 1 day
- Improved developer experience and productivity through actionable findings and reduction of false positives
- Maintenance of superior security standards and inherent policy enforcement with Authorization to Operate (ATO)
Development teams can ship efficiently and ensure applications are cyber ready for Navy Authorizing Officials (AOs). In this webinar, Sigma Defense and Anchore will give attendees a look behind the scenes and demo secure pipeline automation and security artifacts that speed up application ATO and time to production.
We will cover:
- How to remove silos in DevSecOps
- How to build efficient development pipeline roles and component templates
- How to deliver security artifacts that matter for ATO’s (SBOMs, vulnerability reports, and policy evidence)
- How to streamline operations with automated policy checks on container images
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfPaige Cruz
Monitoring and observability aren’t traditionally found in software curriculums and many of us cobble this knowledge together from whatever vendor or ecosystem we were first introduced to and whatever is a part of your current company’s observability stack.
While the dev and ops silo continues to crumble….many organizations still relegate monitoring & observability as the purview of ops, infra and SRE teams. This is a mistake - achieving a highly observable system requires collaboration up and down the stack.
I, a former op, would like to extend an invitation to all application developers to join the observability party will share these foundational concepts to build on:
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
A presentation about the usage and availability of Varnish on Kubernetes. This talk explores the capabilities of Varnish caching and shows how to use the Varnish Helm chart to deploy it to Kubernetes.
This presentation was delivered at K8SUG Singapore. See https://feryn.eu/presentations/accelerate-your-kubernetes-clusters-with-varnish-caching-k8sug-singapore-28-2024 for more details.
Elevating Tactical DDD Patterns Through Object CalisthenicsDorra BARTAGUIZ
After immersing yourself in the blue book and its red counterpart, attending DDD-focused conferences, and applying tactical patterns, you're left with a crucial question: How do I ensure my design is effective? Tactical patterns within Domain-Driven Design (DDD) serve as guiding principles for creating clear and manageable domain models. However, achieving success with these patterns requires additional guidance. Interestingly, we've observed that a set of constraints initially designed for training purposes remarkably aligns with effective pattern implementation, offering a more ‘mechanical’ approach. Let's explore together how Object Calisthenics can elevate the design of your tactical DDD patterns, offering concrete help for those venturing into DDD for the first time!
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofsAlex Pruden
This paper presents Reef, a system for generating publicly verifiable succinct non-interactive zero-knowledge proofs that a committed document matches or does not match a regular expression. We describe applications such as proving the strength of passwords, the provenance of email despite redactions, the validity of oblivious DNS queries, and the existence of mutations in DNA. Reef supports the Perl Compatible Regular Expression syntax, including wildcards, alternation, ranges, capture groups, Kleene star, negations, and lookarounds. Reef introduces a new type of automata, Skipping Alternating Finite Automata (SAFA), that skips irrelevant parts of a document when producing proofs without undermining soundness, and instantiates SAFA with a lookup argument. Our experimental evaluation confirms that Reef can generate proofs for documents with 32M characters; the proofs are small and cheap to verify (under a second).
Paper: https://eprint.iacr.org/2023/1886
3. Why Modern Java Concurrency?
• The WGJD wants to utilise modern hardware
• The WGJD wants to write concurrent code
- Safely
- Without fear
- With an understanding of performance implications
• The WGJD wants to take advantage of:
- JVM support for parallelised operations
- An API that expands on synchronized
• Modern Java Concurrency lets you do all of this
4. About this section
• We only have ~60mins hour to talk today
• Huge amount to talk about
• This subject typically fills 4 days worth of training
• We will give you some highlights today
• For die-hard low latency fiends
- Locks are actually bad hmmkay!
- Come talk to us afterwards to find out more
5. Modern Java concurrency
• Not a new subject
- Underwent a revolution with Java 5
- More refinements in 6 and 7
- Another major library overhaul coming in 8 with lambdas
• java.util.concurrent (j.u.c) really fast in 6
- Better yet in 7 & blazing in 8
• j.u.c. is still under-appreciated
- Too much Java 4-style concurrency code still written
6. Java concurrency - Why not upgrade?
• Too much legacy code?
- People scared to refactor?
• People don’t know j.u.c is easier?
- People don’t know j.u.c is faster than classic?
• People don’t know that you can mix-and-match
- With a bit of care
• Still not being taught at Universities?
• Not enough people reading Doug Lea or Brian Goetz?
8. If you suffer from lutraphobia, you
may want to leave now...
Fluffy cute animals BITE
8
9. Otterly Amazing Tails of Modern Java
Concurrency
• Srsly
- Otters! See those teeth? We warned you.
10. Why Otters?
• Otters are a very good metaphor
- Not just because they look a bit
like threads (i.e. long and thin)
• They are Collaborative,
Competitive & Sneaky
• Hare off in opposite directions
- Wreaking havoc if not contained
11. Otter Management (aka the 4 forces)
• Safety
- Does each object stay self-consistent?
- No matter what other operations are happening?
• Liveness
- Does the program eventually progress?
- Are any failures to progress temporary or permanent?
• Performance
- How well does the system take advantage of cores?
• Reusability
- How easy is it to reuse the system in other applications?
12. Some History
• Until recently, most CPUs had one processing core
• Multithreading was simulated on that single core
- Not true concurrency
• Serial approach to algorithms often sufficed
• Interleaved multithreading can mask errors
- Or be more forgiving than true concurrency
• Why, how and when did things change?
13. Moore’s Law
• “The number of transistors on an economic-to-
produce chip roughly doubles every 2 years”
• Originally stated in 1965
- Expected to hold for the 10 years to 1975
- Still going strong
• Named for Gordon Moore (Intel founder)
- About # transistors, not clock speed or overall performance
16. Moore’s Law - Problems
• Remember, it's not about overall performance
• Memory latency exponent gap
- Need to keep the processing pipeline full
- Add memory caches of faster SRAM “close” to the CPU
• (L1, L2 etc)
• Code is restricted by L1 cache misses
- Rather than CPU speed
- After JIT compilation
17. Spending the transistor budget
• More and more complex contortions...
- ILP, CMT, Branch prediction, etc, etc
18. Multi-core
• If we can’t increase clock speed / performance..
- We have to go multi-core
- Concurrency and performance are now tied together
• Real concurrency
- Separate threads executing on cores at the same moment
• The JVM runtime controls thread scheduling
- Java scheduling does NOT behave like OS scheduling
• Concurrency becomes the performance improver
20. Classic Java Concurrency
• Why synchronized?
• Provides exclusion
• Need locking to make mutation concurrency-safe
• Locking gets complicated
- Can become fragile
22. 3 approaches to Concurrent Type Safety
• Fully-synchronized Objects
- Synchronize all methods on all classes
• Immutability
- Useful, but may have high copy-cost
- Requires programmer discipline
• Be Very, Very Careful
- Difficult
- Fragile
- With Java - Often the only game in town
23. The JMM
• Mathematical description of memory
• Most impenetrable part of the Java language spec
- Even worse than generics
• JMM makes minimum guarantees
• Real JVMs (and CPUs) may do more
- Especially Intel chipsets
26. Synchronizes-with
• Threads have their own desc of an object’s state
- This must be flushed to main memory and other threads
• synchronized means that this local view:
- Has been synchronized-with the other threads
• Defines touch-points where threads must perform
synching
28. java.util.concurrent
• Thanks, Doug Lea and co!
• j.u.c has building blocks for concurrent code
- ReentrantLock
- Condition
- ConcurrentHashMap
- CopyOnWriteArrayList
- Other Concurrent Data Structures
29. Locks in j.u.c
• Lock is an interface
• ReentrantLock is the usual implementation
37. CountDownLatch
• A group consensus construct
• countDown() decrements the count
• await() blocks until count == 0
- i.e. consensus
• Constructor takes an int (the count)
• Quite a few use cases
- e.g. Multithreaded testing
40. Handoff Queue (in-mem)
• Efficient way to hand off work between threadpools
• BlockingQueue a good pick
• Has blocking ops with timeouts
- e.g. for backoff / retry
• Two basic implementations
- ArrayList and LinkedList backed
• Java 7 introduces the shiny new TransferQueue
45. Executors
• j.u.c execution constructs
- Callable, Future, FutureTask
• In addition to the venerable
- Thread and Runnable
• Stop using TimerTask!
• Executors class provides factory methods for
making threadpools
- ScheduledThreadPoolExecutor is one standard choice
49. Fork/Join
• Java 7 introduces F/J
- similar to MapReduce
- useful for a certain class of problems
- F/J executions are not really threads
• In our example, we subclass RecursiveAction
• Need to provide a compute() method
- And a way of merging results
• F/J provides an invokeAll() to hand off more tasks
50. Fork/Join
• Typical divide and conquer style problem
- invokeall() performs the threadpool, worker & queue
magic
51. Concurrent Java Code
• Mutable state (objects) protected by locks
• Concurrent data structures
- CHM, COWAL
• Be careful of performance
- especially COWAL
• Explicit synchronization for multi-threading
• Executor-based threadpools
• Queue-like handoffs used for asynch comms
53. Stepping Back
• Concurrency is key to the future of performant code
• Mutable state is hard
• Need both synch & asynch state sharing
• Locks can be hard to use correctly
• JMM is a low-level, flexible model
- Need higher-level concurrency model
- Thread is still too low-level
54. Imagine a world...
• The JVM helped out the programmer more:
- Runtime-managed concurrency
- Collections were thread-safe by default
- Objects were immutable by default
- State was well encapsulated and not shared by default
• Thread wasn’t the default choice for unit of
concurrent execution
• Copy-on-write was the basis for mutation of
collections / synchronous multithreading
• Hand-off queues were the basis for asynchronous
multithreading
55. What can we do with Java?
• We’re stuck with a lot of heritage in Java
- But the JVM and JMM are very sound
• You don’t have to abandon Java
- Mechanical sympathy and clean code get you far
- The JIT compiler just gets better and better
• If we wanted to dream of a new language
- It should be on the JVM
- It should build on what we’ve learned in 15 years of Java
56. New Frontiers in Concurrency
• There are several options now on the JVM
- New possibilities built-in to the language syntax
- Synch and asynch models
• Scala offers an Actors model
- And the powerful Akka framework
• Clojure is immutable by default
- Has agents (like actors) & shared-nothing by default
- Also has a Software Transactional Memory (STM) model
• Groovy has GPARs
57. Acknowledgments
• All Otter images Creative Commons or Fair Use
• Matt Raible
- 20 criteria of selecting web frameworks
• Ola Bini
- Polyglot pyramid
• Photos owned by Flickr Users
- moff, spark, sodaro, lonecellotheory, tomsowerby
- farnsworth, prince, marcus_jb1973, mliu92, Ed Zitron,
- NaturalLight & monkeywing
• Dancing Otter by the amazing Nicola Slater @ folksy
TODO: If we have time replace code images with actual code\n
Reference the ignite talk\n
\n
\n
* Hands up for Java 6, 5, 4....\n* Hands up for j.u.c\n
* Hands up if you’re daunted by the refactoring that would be required\n\n
\n
\n
\n
They are Apex Predators - think of them in that way\n
The practice of managing your threads (or Otters!) is governed by four forces (after Doug Lea)\n
\n
\n
\n
It’s a little-known fact that Otters are scared of log-linear graphs\n
* TODO: Need better wording for Code is restricted\n* Very successful within own frame of reference, but caveats\n* Reference Mechanical sympathy again here\n
* So you can contort more and more, but you’re chasing diminishing returns\n* Ultimately, that exponent gap between clock speed and memory will do for you\n
* Raise your hand if you use the process monitor on Ubuntu or another Linux. OK, have you seen how Java processes behave under that?\n
\n
* Explain that we’re going to show replacements for using synchronized\n* Raise your hand if you know why we use the keyword “synchronized” to denote a critical section in Java\n
\n
How performant do we think FS objects are?\nImmutability is good, but watch the copy-cost\n
\n\n
happens-before defines a “partial order” (if you’re a mathematician)\n\n
\n
* Hands up if you know what a (Non-Uniform Memory Access) NUMA architecture is?\n* In some ways, this is actually easier to explain on a NUMA arch...\n
\n
\n
* Lock can in some cases directly replace synchronized, but is more flexible\n* MONITORENTER & MONITOREXIT\n* We use reentrant lock else recursive code deadlocks real quick\n
TODO: Are we going to do the condition wait/notify sketch?\n
Condition takes the place of wait() / notify() (Object monitors)\nTalk to the cases - 1 putter, 1 taker, many putters, few takers, few putters, many takers - think about this stuff at the design stage\n
\n
“What’s the worst thing that can happen if you’re iterating over the keys of a regular HashMap and someone alters it underneath you?”\n
Basically it’s a drop-in replacement for regular HashMap\n
\n
Not quite a drop-in replacement - Performance needs to be thought about\nTODO Need to fix code sample so we have iterators\n
\n
\n
\n
\n\n
BlockingQueue offers several different ways to interact with it (see the Javadoc)\n\n
\n
offer is similar to add but doesn’t throw exceptions\nProducers adding trade orders for example\nTODO Theatresports?\n
Final building block for modern concurrent applications with Java\n
\n
\n
* Let’s step through a quasi-realistic example\n* That cancel() code begs for some of that lambda treatment huh!\n
\n
\n\n
As well as RecursiveAction there’s the more general ForkJoinTask\n\n
Multithreaded Quicksort - shows a speedup from O(nlog n) to O(n) - not quite linear, but not bad\n
So this is pretty much a statement of the state-of-the-art in Java concurrency\n
\n
* Thread is the assembly language of concurrency\n* We need to move to a more managed model\n