多線程,嵌入到接口裏面

Object lock = new Object();
        class ChannelThread extends Thread {
            private String data_type;
            private String shop_range;
            private String gender;
            private String age;
            private String purchase;
            private String arrival_count;
            private String arrival_floor;
            private String arrival_path;
            private String arrival_range;
            private String arrival_time;
            public ChannelThread( String data_type, String shop_range, String gender, String age, String purchase, String arrival_count, String arrival_floor, String arrival_path, String arrival_range, String arrival_time) {
                this.data_type=data_type;
                this.shop_range=shop_range;
                this.gender=gender;
                this.age=age;
                this.purchase=purchase;
                this.arrival_count=arrival_count;
                this.arrival_floor=arrival_floor;
                this.arrival_path=arrival_path;
                this.arrival_range=arrival_range;
                this.arrival_time=arrival_time;
            }

            @Override
            public void run() {
                RestResultVo circle_analysis_info = getList(request, this.data_type, this.shop_range, this.gender, this.age, this.purchase, this.arrival_count, this.arrival_floor, this.arrival_path, this.arrival_range, this.arrival_time);
                synchronized (lock) {
                    value_map.put(this.arrival_path, circle_analysis_info);
                }
            }
        }
        ExecutorService exe = Executors.newFixedThreadPool(50);
        for (int j = 0; j < pointSize; j++) {
            if ("4".equals(data_type)) {
                arrival_path = point[j];
            }
            ChannelThread channelThread = new ChannelThread(data_type, shop_range, gender, age, purchase, arrival_count, arrival_floor, arrival_path, arrival_range, arrival_time);
            exe.execute(channelThread);
        }
        exe.shutdown();
        while (true) {
            if (exe.isTerminated()) {
                break;
            }
            try {
                Thread.sleep(200);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        break;
    }
}
相關文章
相關標籤/搜索