SlideShare a Scribd company logo
@juanplopes




JAVA
       PARA
       PROGRAMADORES
       .NET
Rio de Janeiro
Bel' Zonte
Em comunidades,
pessoas antes de tecnologias.
REVELAÇÃO!
REVELAÇÃO!




https://github.com/juanplopes/mublasters
devday2012
VAMOS FALAR
  MAL DE
SISTEMA DE TIPOS NÃO É
        UNIFICADO



    NÃO TEM STRUCTS




GENERICS TEM TYPE ERASURE
API DE DATAS SOFRÍVEL




 NÃO TEM ITERATOR METHODS




NÃO TEM CLOSURES OU LAMBDAS
devday2012
java.util.concurrent
NÃO CRIE THREADS


new Thread(new Runnable() {
    public void run() {

    }
}).start();
TRABALHANDO COM FUTURES


Future é a promessa do resultado de
    uma computação que ainda não
   terminou (ou sequer começou).
TRABALHANDO COM FUTURES

ExecutorService executor = ...

Future future = executor.submit(new Runnable() {
    public void run() {

      }
});

//qualquer outro trabalho

future.get(); //bloqueante
TRABALHANDO COM FUTURES

ExecutorService executor = ...

Future<String> future = executor.submit(new Callable<String>()
{
    public String call() {
       return "42";
    }
});

//qualquer outro trabalho

String result = future.get(); //bloqueante
.NET TASK FACTORY

TaskFactory factory = ...

var task = factory.StartNew(() => "42");

//qualquer outro trabalho

String result = future.Result; //bloqueante
.NET TASK FACTORY


      Java 5 (2004)
ExecutorService e Future<T>

      .NET 4 (2010)
TaskFactory, TaskScheduler e
           Task<T>
TRABALHANDO COM FUTURES


Executors
   newCachedThreadPool()
   newFixedThreadPool(n)
   newScheduledThreadPool(n)
   newSingleThreadExecutor()

guava.MoreExecutors
   sameThreadExecutor()
   listeningDecorator(executor)
E A SINCRONIZAÇÃO?
COLEÇÕES CONCORRENTES


ConcurrentMap<T, K>

  putIfAbsent(key, value)
  remove(key, value)
  replace(key, value)
  replace(key, oldValue, newValue)
COLEÇÕES CONCORRENTES


ConcurrentNavigableMap<T, K>

  headMap(toKey)
  tailMap(fromKey)
  subMap(fromKey, toKey)
PROBLEMA DO PRODUTOR-
     CONSUMIDOR


     produz            consome



 A            BUFFER             B
COLEÇÕES BLOQUEANTES


ArrayBlockingQueue<T>,
PriorityBlockingQueue<T>
DelayQueue<T>

  Exception: add, remove
  Retorna Flag: offer, poll
  Bloqueia: put, take
  Timeout: offer², poll²
ESTRUTURAS DE DADOS DE
    SINCRONIZAÇÃO

Semaphore

  acquire(number)
  release(number)
ESTRUTURAS DE DADOS DE
    SINCRONIZAÇÃO

CountDownLatch

  countDown()
  await()
ESTRUTURAS DE DADOS DE
    SINCRONIZAÇÃO

CyclicBarrier

  await()
OPEN SOURCE
APACHE

         Hadoop
         Lucene
         Maven
         Tomcat
         ZooKeeper
         HBase
         Solr
         ActiveMQ
         Ant
         Log4J
RED HAT

          Hibernate
          JBoss
          TorqueBox
          JGroups
          Infinispan
          AeroGear
          Drools
          EJB3
          HornetQ
          RichFaces
GOOGLE

         Guava
         Guice ('Juice')
         Gson
         Protocol Buffers
         Contracts
         GWT
         Caliper
OPEN JDK
APACHE MAVEN

<dependency>
    <groupId>...</groupId>
    <artifactId>...</artifactId>
    <version>...</version>
</dependency>
APACHE MAVEN
JGROUPS

JChannel channel = new JChannel();
channel.setReceiver(new ReceiverAdapter() {
    public void receive(Message msg) {
        System.out.println(
            msg.getSrc() + ": " + msg.getObject());
    }
});

channel.connect("meuCanalDeChat");

BufferedReader reader = new BufferedReader(
                       new InputStreamReader(System.in));
while(true) {
   String line = reader.readLine();
   channel.send(null, line);
}
GUAVA

Preconditions
Immutable Collections
Caching
Functional Idioms
Signed Numbers
Reflection
Math
Optimized Data Structures
Simplified I/O
GUAVA

LoadingCache<Key, Graph> graphs = CacheBuilder.newBuilder()
    .maximumSize(1000)
    .expireAfterWrite(10, TimeUnit.MINUTES)
    .removalListener(MY_LISTENER)
    .build(new CacheLoader<Key, Graph>() {
        public Graph load(Key key) throws AnyException {
            return createExpensiveGraph(key);
        }
    });
GUICE ou SPRING?




É mais rápido             Mais usuários
Sem XML                    Não é só IOC
Menos Annotations        Integra melhor
Melhores convenções   Mais documentação
AOP embutido
MOCKITO


when(obj.method()).thenReturn(42);

verify(obj).method();
LINGUAGENS ALTERNATIVAS

●   JRuby
●   Clojure
●   Scala
●   Groovy
●   DynJS
IDE
IDEs
       IDE
HOTSPOT
JIT E ADAPTIVE OPTIMIZATION

Loop Unrolling
Method inlining
Exact Type Inference
Type Test Strength Reduction
Dead Code Elimination
Tiered Compilation
Lock Elision
Dereflection
Autobox Elimination
GC: CONCURRENT MARK SWEEP
JVISUALVM
JVISUALVM
YOURKIT PROFILER
Tecnologia não é religião,
time de futebol ou partido
         político.
Obrigado.

More Related Content

PDF
Riga Dev Day 2016 - Having fun with Javassist
PDF
Dagger & rxjava & retrofit
PDF
Counter Wars (JEEConf 2016)
PDF
Software Testing - Invited Lecture at UNSW Sydney
PDF
JavaOne 2015 - Having fun with Javassist
PDF
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
PDF
No dark magic - Byte code engineering in the real world
PDF
Jakarta Commons - Don't re-invent the wheel
Riga Dev Day 2016 - Having fun with Javassist
Dagger & rxjava & retrofit
Counter Wars (JEEConf 2016)
Software Testing - Invited Lecture at UNSW Sydney
JavaOne 2015 - Having fun with Javassist
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
No dark magic - Byte code engineering in the real world
Jakarta Commons - Don't re-invent the wheel

What's hot (20)

PDF
Java 7 LavaJUG
PDF
Understanding greenlet
KEY
Gevent what's the point
PDF
Jenkins 2を使った究極のpipeline ~ 明日もう一度来てください、本物のpipelineをお見せしますよ ~
PPTX
Jdk 7 4-forkjoin
PDF
ESCMAScript 6: Get Ready For The Future. Now
PDF
Oredev 2015 - Taming Java Agents
PPTX
RuntimeUnitTestToolkit for Unity(English)
PDF
Memory Management of C# with Unity Native Collections
PDF
Construire une application JavaFX 8 avec gradle
PDF
Java9を迎えた今こそ!Java本格(再)入門
PDF
DevoxxPL: JRebel Under The Covers
PDF
Testing with Node.js
PPTX
разработка серверов и серверных приложений лекция №4
PPTX
Performance is a feature! - Developer South Coast - part 2
PDF
Qt Rest Server
PDF
Server1
PDF
Is your profiler speaking the same language as you? -- Docklands JUG
PPTX
Nantes Jug - Java 7
PDF
Spock: A Highly Logical Way To Test
Java 7 LavaJUG
Understanding greenlet
Gevent what's the point
Jenkins 2を使った究極のpipeline ~ 明日もう一度来てください、本物のpipelineをお見せしますよ ~
Jdk 7 4-forkjoin
ESCMAScript 6: Get Ready For The Future. Now
Oredev 2015 - Taming Java Agents
RuntimeUnitTestToolkit for Unity(English)
Memory Management of C# with Unity Native Collections
Construire une application JavaFX 8 avec gradle
Java9を迎えた今こそ!Java本格(再)入門
DevoxxPL: JRebel Under The Covers
Testing with Node.js
разработка серверов и серверных приложений лекция №4
Performance is a feature! - Developer South Coast - part 2
Qt Rest Server
Server1
Is your profiler speaking the same language as you? -- Docklands JUG
Nantes Jug - Java 7
Spock: A Highly Logical Way To Test
Ad

Viewers also liked (20)

PPTX
Guía completa de linkbuilding - La visión más realista
PDF
Gluster open stack dev summit 042011
PPT
产品经理的视角
PPTX
Do you really get class loaders?
PDF
On The Road
PDF
CEO Survey 2014 - Poimintoja Suomen tuloksista
PDF
After Real Time Advertising
PPT
Why APIs are not SOA++
PDF
Emagineers - Design & Test Report
PDF
Mobile Device Management: Securing your Mobile Environment.
PDF
5050 project update
PDF
Dependency injection in scala
PDF
Editorial Strategy: The Missing Link in Civic Data Tools, Transparency Camp 2015
PPTX
Secrets of a successful e-commerce website
PPT
Four Country Mobile Operator Study: a competitive benchmark of leading mobile...
ODP
High Performance Web Sites
PPTX
Raymond - Social Media Strategy
PPTX
KG이니시스 회사 소개서
PPT
Embrace Uncertainty
PDF
2015 WebConf - Web + Arduino 實在有夠潮
Guía completa de linkbuilding - La visión más realista
Gluster open stack dev summit 042011
产品经理的视角
Do you really get class loaders?
On The Road
CEO Survey 2014 - Poimintoja Suomen tuloksista
After Real Time Advertising
Why APIs are not SOA++
Emagineers - Design & Test Report
Mobile Device Management: Securing your Mobile Environment.
5050 project update
Dependency injection in scala
Editorial Strategy: The Missing Link in Civic Data Tools, Transparency Camp 2015
Secrets of a successful e-commerce website
Four Country Mobile Operator Study: a competitive benchmark of leading mobile...
High Performance Web Sites
Raymond - Social Media Strategy
KG이니시스 회사 소개서
Embrace Uncertainty
2015 WebConf - Web + Arduino 實在有夠潮
Ad

Similar to devday2012 (20)

PDF
De Java 8 ate Java 14
PDF
What's new in Java EE 7? From HTML5 to JMS 2.0
PDF
De Java 8 a Java 11 y 14
PPTX
Java ee 7 New Features
PDF
Xebia Knowledge Exchange (feb 2011) - Large Scale Web Development
PDF
Powering the Next Generation Services with Java Platform - Spark IT 2010
KEY
Devignition 2011
PDF
The State of Java under Oracle at JCertif 2011
ODP
JUDCON India 2014 Java EE 7 talk
PDF
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
PDF
De Java 8 a Java 17
PDF
wtf is in Java/JDK/wtf7?
PDF
Highlights from Java 10-13 and Future of Java at JCON 2019 by Alukhanov and K...
PDF
The spring 32 update final
PPTX
Java 7 Whats New(), Whats Next() from Oredev
ODP
Enterprise Java in 2012 and Beyond, by Juergen Hoeller
ODP
JBUG.be Infinispan
PDF
JavaOne 2010 Keynote
PDF
Spring Boot 3 And Beyond
KEY
Modern Java Concurrency
De Java 8 ate Java 14
What's new in Java EE 7? From HTML5 to JMS 2.0
De Java 8 a Java 11 y 14
Java ee 7 New Features
Xebia Knowledge Exchange (feb 2011) - Large Scale Web Development
Powering the Next Generation Services with Java Platform - Spark IT 2010
Devignition 2011
The State of Java under Oracle at JCertif 2011
JUDCON India 2014 Java EE 7 talk
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
De Java 8 a Java 17
wtf is in Java/JDK/wtf7?
Highlights from Java 10-13 and Future of Java at JCON 2019 by Alukhanov and K...
The spring 32 update final
Java 7 Whats New(), Whats Next() from Oredev
Enterprise Java in 2012 and Beyond, by Juergen Hoeller
JBUG.be Infinispan
JavaOne 2010 Keynote
Spring Boot 3 And Beyond
Modern Java Concurrency

More from Juan Lopes (10)

PDF
qconrio2015
PDF
qconsp2015
PDF
PIPES: Uma linguagem para processamento distribuído de eventos complexos
PDF
devday2013
PDF
dnarj20130504
PDF
uerj201212
PDF
rioinfo2012
PDF
tdc2012
PDF
dnarj-20120630
PDF
dnad12
qconrio2015
qconsp2015
PIPES: Uma linguagem para processamento distribuído de eventos complexos
devday2013
dnarj20130504
uerj201212
rioinfo2012
tdc2012
dnarj-20120630
dnad12

Recently uploaded (20)

PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Machine learning based COVID-19 study performance prediction
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Cloud computing and distributed systems.
PDF
Empathic Computing: Creating Shared Understanding
PDF
Encapsulation theory and applications.pdf
PPTX
Spectroscopy.pptx food analysis technology
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
Machine learning based COVID-19 study performance prediction
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Approach and Philosophy of On baking technology
Per capita expenditure prediction using model stacking based on satellite ima...
Chapter 3 Spatial Domain Image Processing.pdf
MYSQL Presentation for SQL database connectivity
Mobile App Security Testing_ A Comprehensive Guide.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
The Rise and Fall of 3GPP – Time for a Sabbatical?
Advanced methodologies resolving dimensionality complications for autism neur...
Cloud computing and distributed systems.
Empathic Computing: Creating Shared Understanding
Encapsulation theory and applications.pdf
Spectroscopy.pptx food analysis technology
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
20250228 LYD VKU AI Blended-Learning.pptx

devday2012