Concurrency Problem                                      Adriano Patrick Cunha - UDCEquarta-feira, 10 de outubro de 2012
Evolution of processorsquarta-feira, 10 de outubro de 2012
Big Data to processquarta-feira, 10 de outubro de 2012
What Possibilities ?quarta-feira, 10 de outubro de 2012
Concurrence?quarta-feira, 10 de outubro de 2012
Which options ?quarta-feira, 10 de outubro de 2012
Functional Programming language ?quarta-feira, 10 de outubro de 2012
API java.util.concurrent                              5quarta-feira, 10 de outubro de 2012
Thead-Safequarta-feira, 10 de outubro de 2012
Thead-Safe      private	  Set<String>	  ipAddressSet	  =	  new	  HashSet<String>();quarta-feira, 10 de outubro de 2012
Thead-Safe      private	  Set<String>	  ipAddressSet	  =	  new	  HashSet<String>();   	  private	  Set<String>	  ipAddress...
Thead-Safe      private	  Set<String>	  ipAddressSet	  =	  new	  HashSet<String>();   	  private	  Set<String>	  ipAddress...
Thead-Safe                                          fast-fail iterators      private	  Set<String>	  ipAddressSet	  =	  ne...
Thead-Safe            Outras	  Coleções                                ConcurrentHashMap,	  CopyOnWriteArrayList	  e	     ...
Executor                                             Executor                                          ExecutorService    ...
Executor                                      (new Thread(r)).start();quarta-feira, 10 de outubro de 2012
Executor                                      (new Thread(r)).start();                                           e.execute...
Thread Pools                 Executors.newCachedThreadPool();                                      Executors.newFixedThrea...
Thread Pools                                                 class Counter {                                              ...
Thread Pools                                      class SynchronizedCounter {                                          pri...
Thread Pools                                      import java.util.concurrent.atomic.AtomicInteger;                       ...
Bibliografia        Livros        Concurrent Programming in Java, Design Principles and Patterns, Doug Lea, Addison-Wesley,...
Upcoming SlideShare
Loading in …5
×

Concurrencyproblem

424 views

Published on

Published in: Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
424
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Concurrencyproblem

  1. 1. Concurrency Problem Adriano Patrick Cunha - UDCEquarta-feira, 10 de outubro de 2012
  2. 2. Evolution of processorsquarta-feira, 10 de outubro de 2012
  3. 3. Big Data to processquarta-feira, 10 de outubro de 2012
  4. 4. What Possibilities ?quarta-feira, 10 de outubro de 2012
  5. 5. Concurrence?quarta-feira, 10 de outubro de 2012
  6. 6. Which options ?quarta-feira, 10 de outubro de 2012
  7. 7. Functional Programming language ?quarta-feira, 10 de outubro de 2012
  8. 8. API java.util.concurrent 5quarta-feira, 10 de outubro de 2012
  9. 9. Thead-Safequarta-feira, 10 de outubro de 2012
  10. 10. Thead-Safe private  Set<String>  ipAddressSet  =  new  HashSet<String>();quarta-feira, 10 de outubro de 2012
  11. 11. Thead-Safe private  Set<String>  ipAddressSet  =  new  HashSet<String>();  private  Set<String>  ipAddressSet  =  Collections.              synchonizedSet(new  HashSet<String>());quarta-feira, 10 de outubro de 2012
  12. 12. Thead-Safe private  Set<String>  ipAddressSet  =  new  HashSet<String>();  private  Set<String>  ipAddressSet  =  Collections.              synchonizedSet(new  HashSet<String>());private  BlockingQueue<String>  ipAddress=new  LinkedBlockingQueue<String>();quarta-feira, 10 de outubro de 2012
  13. 13. Thead-Safe fast-fail iterators private  Set<String>  ipAddressSet  =  new  HashSet<String>();  private  Set<String>  ipAddressSet  =  Collections.              synchonizedSet(new  HashSet<String>());private  BlockingQueue<String>  ipAddress=new  LinkedBlockingQueue<String>(); weakly consistent iteratorsquarta-feira, 10 de outubro de 2012
  14. 14. Thead-Safe Outras  Coleções ConcurrentHashMap,  CopyOnWriteArrayList  e   CopyOnWriteArraySetquarta-feira, 10 de outubro de 2012
  15. 15. Executor Executor ExecutorService ScheduledExecutorServicequarta-feira, 10 de outubro de 2012
  16. 16. Executor (new Thread(r)).start();quarta-feira, 10 de outubro de 2012
  17. 17. Executor (new Thread(r)).start(); e.execute(r);quarta-feira, 10 de outubro de 2012
  18. 18. Thread Pools Executors.newCachedThreadPool(); Executors.newFixedThreadPoll(n); Executors.newSingleThreadExecutor();quarta-feira, 10 de outubro de 2012
  19. 19. Thread Pools class Counter { private int c = 0; public void increment() { c++; } public void decrement() { c--; } public int value() { return c; } } 1. Thread A: Retrieve c. 2. Thread B: Retrieve c. 1. Retrieve the current value of c. 3. Thread A: Increment retrieved value; result is 1. 2. Increment the retrieved value by 1. 4. Thread B: Decrement retrieved value; result is -1. 3. Store the incremented value back in c. 5. Thread A: Store result in c; c is now 1. 6. Thread B: Store result in c; c is now -1.quarta-feira, 10 de outubro de 2012
  20. 20. Thread Pools class SynchronizedCounter { private int c = 0; public synchronized void increment() { c++; } public synchronized void decrement() { c--; } public synchronized int value() { return c; } }quarta-feira, 10 de outubro de 2012
  21. 21. Thread Pools import java.util.concurrent.atomic.AtomicInteger; class AtomicCounter { private AtomicInteger c = new AtomicInteger(0); public void increment() { c.incrementAndGet(); } public void decrement() { c.decrementAndGet(); } public int value() { return c.get(); } }quarta-feira, 10 de outubro de 2012
  22. 22. Bibliografia Livros Concurrent Programming in Java, Design Principles and Patterns, Doug Lea, Addison-Wesley, 1999 Java Concurrency In Practice, Brian Goetz, Addison-Wesley, 2006 Links http://docs.oracle.com/javase/tutorial/essential/concurrency/index.html http://www.jcp.org/en/jsr/detail?id=166 http://gee.cs.oswego.edu/dl/concurrency-interest/ http://www.devmedia.com.br/websys.2/webreader.asp?cat=6&revista=javamagazine_69quarta-feira, 10 de outubro de 2012

×