Advertisement

devday2012

Software developer at Intelie
Oct. 20, 2012
Advertisement

More Related Content

Advertisement
Advertisement

devday2012

  1. @juanplopes JAVA PARA PROGRAMADORES .NET
  2. Rio de Janeiro
  3. Bel' Zonte
  4. Em comunidades, pessoas antes de tecnologias.
  5. REVELAÇÃO!
  6. REVELAÇÃO! https://github.com/juanplopes/mublasters
  7. VAMOS FALAR MAL DE
  8. SISTEMA DE TIPOS NÃO É UNIFICADO NÃO TEM STRUCTS GENERICS TEM TYPE ERASURE
  9. API DE DATAS SOFRÍVEL NÃO TEM ITERATOR METHODS NÃO TEM CLOSURES OU LAMBDAS
  10. java.util.concurrent
  11. NÃO CRIE THREADS new Thread(new Runnable() { public void run() { } }).start();
  12. TRABALHANDO COM FUTURES Future é a promessa do resultado de uma computação que ainda não terminou (ou sequer começou).
  13. TRABALHANDO COM FUTURES ExecutorService executor = ... Future future = executor.submit(new Runnable() { public void run() { } }); //qualquer outro trabalho future.get(); //bloqueante
  14. 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
  15. .NET TASK FACTORY TaskFactory factory = ... var task = factory.StartNew(() => "42"); //qualquer outro trabalho String result = future.Result; //bloqueante
  16. .NET TASK FACTORY Java 5 (2004) ExecutorService e Future<T> .NET 4 (2010) TaskFactory, TaskScheduler e Task<T>
  17. TRABALHANDO COM FUTURES Executors newCachedThreadPool() newFixedThreadPool(n) newScheduledThreadPool(n) newSingleThreadExecutor() guava.MoreExecutors sameThreadExecutor() listeningDecorator(executor)
  18. E A SINCRONIZAÇÃO?
  19. COLEÇÕES CONCORRENTES ConcurrentMap<T, K> putIfAbsent(key, value) remove(key, value) replace(key, value) replace(key, oldValue, newValue)
  20. COLEÇÕES CONCORRENTES ConcurrentNavigableMap<T, K> headMap(toKey) tailMap(fromKey) subMap(fromKey, toKey)
  21. PROBLEMA DO PRODUTOR- CONSUMIDOR produz consome A BUFFER B
  22. COLEÇÕES BLOQUEANTES ArrayBlockingQueue<T>, PriorityBlockingQueue<T> DelayQueue<T> Exception: add, remove Retorna Flag: offer, poll Bloqueia: put, take Timeout: offer², poll²
  23. ESTRUTURAS DE DADOS DE SINCRONIZAÇÃO Semaphore acquire(number) release(number)
  24. ESTRUTURAS DE DADOS DE SINCRONIZAÇÃO CountDownLatch countDown() await()
  25. ESTRUTURAS DE DADOS DE SINCRONIZAÇÃO CyclicBarrier await()
  26. OPEN SOURCE
  27. APACHE Hadoop Lucene Maven Tomcat ZooKeeper HBase Solr ActiveMQ Ant Log4J
  28. RED HAT Hibernate JBoss TorqueBox JGroups Infinispan AeroGear Drools EJB3 HornetQ RichFaces
  29. GOOGLE Guava Guice ('Juice') Gson Protocol Buffers Contracts GWT Caliper
  30. OPEN JDK
  31. APACHE MAVEN <dependency> <groupId>...</groupId> <artifactId>...</artifactId> <version>...</version> </dependency>
  32. APACHE MAVEN
  33. 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); }
  34. GUAVA Preconditions Immutable Collections Caching Functional Idioms Signed Numbers Reflection Math Optimized Data Structures Simplified I/O
  35. 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); } });
  36. 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
  37. MOCKITO when(obj.method()).thenReturn(42); verify(obj).method();
  38. LINGUAGENS ALTERNATIVAS ● JRuby ● Clojure ● Scala ● Groovy ● DynJS
  39. IDE
  40. IDEs IDE
  41. HOTSPOT
  42. 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
  43. GC: CONCURRENT MARK SWEEP
  44. JVISUALVM
  45. JVISUALVM
  46. YOURKIT PROFILER
  47. Tecnologia não é religião, time de futebol ou partido político.
  48. Obrigado.
Advertisement