Giter Club home page Giter Club logo

mthread's Introduction

monitor-thread

普通JDK自带的线程池时无法实现线程池的自动切换,基于监控与上下文自动切换的需求,封住了一套taxi开头的线程池,接入方式很简单,它的使用方式与Jdk的使用基本方式一致,只需在对应的类前加一个Taxi,现将对应方式列举如下: 1)Executors<-------->TaxiExecutors Example: private final ExecutorService producerPool = TaxiExecutors.newCachedThreadPool(new ThreadFactoryBuilder("Scheduled-EncourageOrderPushProducer-scheduler"));

2)ScheduledThreadPoolExecutor<-------->WrapTaxiScheduledThreadPoolExecutor Example: private WrapTaxiScheduledThreadPoolExecutor executor = new WrapTaxiScheduledThreadPoolExecutor(2, new ThreadFactoryBuilder("TimerMonitorImpl-executor"));

3)ThreadPoolExecutor<-------->TaxiThreadPoolExecutor Example:private final ExecutorService dataFlushExecutor = new TaxiThreadPoolExecutor(100, 200, 60L,TimeUnit.SECONDS, new LinkedBlockingDeque(5000000), new ThreadFactoryBuilder( "DataFlush-executor"));

4)Callable<-------->TaxiCallableWrapper Example:public Future submit(Callable task) { return schedule(new TaxiCallableWrapper(task), 0, TimeUnit.NANOSECONDS); }

5)Runnable<-------->TaxiRunnableWrapper Example:public void execute(Runnable command) { schedule(new TaxiRunnableWrapper(command), 0, TimeUnit.NANOSECONDS); }

应用依赖的Log4j中做如下配置

mthread's People

Contributors

290420058 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.