Package com.workplacesystems.utilsj.threadpool

Examples of com.workplacesystems.utilsj.threadpool.ThreadPoolCreator


        private final List<EventCallback> event_callbacks = Collections.synchronizedList(new ArrayList<EventCallback>());

        private EventConnection(InetAddress server, int port)
        {
            super(server, port, false);
            ThreadPoolCreator tp_creator = new ThreadPoolCreator() {

                public ThreadObjectFactory getThreadObjectFactory() {
                    return new ThreadObjectFactory() {
                        @Override
                        public void initialiseThread(Thread thread)
                        {
                            thread.setName("Event");
                        }

                        @Override
                        public void activateThread(Thread thread)
                        {
                        }

                        @Override
                        public void passivateThread(Thread thread)
                        {
                        }
                    };
                }

                public Config getThreadPoolConfig() {
                    Config config = new Config();
                    config.maxActive = 10;
                    config.minIdle   = 2;
                    config.maxIdle   = 5;
                    config.testOnBorrow = false;
                    config.testOnReturn = true;
                    config.whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_BLOCK;
                    config.maxWait = -1;
                    return config;
                }

                public String getThreadPoolName() {
                    return "EventPool";
                }
            };
            event_callback_pool = new ThreadPool(tp_creator.getThreadObjectFactory(), tp_creator.getThreadPoolConfig());
        }
View Full Code Here


        private final List<StatusChangeCallback> sc_callbacks = Collections.synchronizedList(new ArrayList<StatusChangeCallback>());

        private StatusChangeConnection(InetAddress server, int port)
        {
            super(server, port, false);
            ThreadPoolCreator tp_creator = new ThreadPoolCreator() {

                public ThreadObjectFactory getThreadObjectFactory() {
                    return new ThreadObjectFactory() {
                        @Override
                        public void initialiseThread(Thread thread)
                        {
                            thread.setName("StatusChange");
                        }

                        @Override
                        public void activateThread(Thread thread)
                        {
                        }

                        @Override
                        public void passivateThread(Thread thread)
                        {
                        }
                    };
                }

                public Config getThreadPoolConfig() {
                    Config config = new Config();
                    config.maxActive = 10;
                    config.minIdle   = 2;
                    config.maxIdle   = 5;
                    config.testOnBorrow = false;
                    config.testOnReturn = true;
                    config.whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_BLOCK;
                    config.maxWait = -1;
                    return config;
                }

                public String getThreadPoolName() {
                    return "StatusChangePool";
                }
            };
            sc_callback_pool = new ThreadPool(tp_creator.getThreadObjectFactory(), tp_creator.getThreadPoolConfig());
        }
View Full Code Here

TOP

Related Classes of com.workplacesystems.utilsj.threadpool.ThreadPoolCreator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.