Java re-learning--executor,executorservice,scheduledexecutorservice and executors

Source: Internet
Author: User

1,executor, Executorservice, and Scheduledexecutorservice, they're all interfaces, Their relationship is scheduledexecutorservice inherit Executorservice and Executorservice and inherit executor.

These can be seen as a bit of open source code.

2, for the executor interface, it has only one method, void execute (Runnable command), and the subsequent executorservice and scheduledexecutorservice each add to their respective methods.

The executorservice is mainly related to the thread pool, while Scheduledexecutorservice is used to perform timed tasks.

3, because they are all interfaces, so to instantiate the word must have a common class, but Java provides a factory class executors specifically generated a variety of executor, shaped like:

Scheduledexecutorservice se = executors.newsinglethreadscheduledexecutor ();         = Executors.newcachedthreadpool ();

Java re-learning--executor,executorservice,scheduledexecutorservice and executors

Related Article

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.