Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

JDD 2016 - Christin Gorman - Concurrency in Java

65 views

Published on

Async and non-blocking are the concepts du jour when it comes to concurrency on the JVM. If you want to go web scale, if you want to maximize concurrent performance, you just cannot afford to block.
But why? Blocking is not a problem in Erlang. Nor is it a problem in Go. How come we can't block on the JVM? And how does a non blocking request for data from a remote service actually work? I'll illustrate the whys, whens and hows with some simple code examples in plain java. Then I'll show you some practical examples of how to solve common programming problems in non-blocking frameworks like Vertx.io, Akka and Quasar.
Is the future non-blocking, or should we all start learning Erlang?

Published in: Technology
  • Be the first to comment

  • Be the first to like this

JDD 2016 - Christin Gorman - Concurrency in Java

  1. 1. CONCURRENCY IN JAVA KODEMAKER @ChristinGorman
  2. 2. WHAT IS CONCURRENCY?
  3. 3. PARALLEL http://thesuccesscommunityonline.com/wp-content/uploads/2012/12/shutterstock_Reading-Toilet.jpg
  4. 4. CONCURRENT http://cdn.mommyish.com/files/2012/01/782888942.jpg
  5. 5. WAITING WAITING WAITING WAITING
  6. 6. for (int i = 0; i < 1000; i++) { new Thread(() -> Thread.sleep(1000)).start(); }
  7. 7. NO PROBLEM
  8. 8. for (int i = 0; i < 3000; i++) { new Thread(() -> Thread.sleep(1000)).start(); }
  9. 9. java.lang.OutOfMemoryError
  10. 10. !?!?!?
  11. 11. 2016
  12. 12. ExecutorService exec = Executors.newFixedThreadPool(1000); for (int i = 0; i < 3000; i++) { exec.submit(() -> Thread.sleep(1000)); }
  13. 13. DEMO
  14. 14. “Synchronous RPC is the crack cocaine of distributed programming”
 -@mjpt777
  15. 15. THANK YOU! @ChristinGorman

×