java concurrent programming notes (nine) - multithreading Best Practices

java concurrent programming notes (nine) - multithreading Best Practices

  • Use local variables

  • Immutable class

  • Minimizing scope lock range

  • Use the thread pool Executor, rather than directly execute new Thread

  • Rather synchronous and do not use threads wait and notify

  • Use BlockingQueue achieve the production - consumption patterns

  • Use concurrent collections, rather than the addition of synchronized set of locks (such as Collections.synchronized try to avoid using these collections, special collections should JUC synchronization provided)

  • Use Semaphore to create an access bounded

  • Rather use the synchronization code blocks do not use the method of synchronizing

  • Avoid using static variables

Guess you like

Origin www.cnblogs.com/xujie09/p/11704999.html