[Java Multithreading] Linkedblockingqueue

Source: Internet
Author: User

The new class under the Java.util.concurrent package. is one of LinkedBlockingQueue them, is a blocked thread-safe queue, with the underlying implementation of a linked list.

Linkedblockingqueue

LinkedBlockingQueueIf no size is specified at the time of construction, the default size is Integer.MAX_VALUE , and of course you can specify the size in the parameters of the constructor

  • Create a thread pool, queue based on Linkedblockingqueue
lazy val executor =  new ThreadPoolExecutor(20, 20, 0L, TimeUnit.MILLISECONDS,      //基于阻塞队列,大小设置为100      new LinkedBlockingQueue(100),      //拒绝策略,当队列满了之后,又达到了max size,将会将任务提交到主线程中进行处理      new ThreadPoolExecutor.CallerRunsPolicy()    )    // println(s"THREADS = $THREADS")    // Executors.newFixedThreadPool(THREADS)  }

[Java Multithreading] Linkedblockingqueue

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.