package com.hust.grid.leesf.entrance; import java.util.Timer; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; import com.hust.grid.leesf.bean.IpInfo; import com.hust.grid.leesf.thread.IPCollectTask; import com.hust.grid.leesf.thread.VoteThread; public class Vote { private BlockingQueue<IpInfo> ipInfoQueue; private IPCollectTask ipCollectTask; private VoteThread voteThread; public Vote() { ipInfoQueue = new LinkedBlockingQueue<IpInfo>(); ipCollectTask = new IPCollectTask(ipInfoQueue); voteThread = new VoteThread(ipInfoQueue); } public void vote() { Timer timer = new Timer(); long delay = 0; long period = 1000 * 60 * 60; // 每一个小时采集一次ip timer.scheduleAtFixedRate(ipCollectTask, delay, period); // 开启投票任务 voteThread.start(); } main(String[] args) { Vote vote = new Vote(); vote.vote(); } }
View Code3.IPCollectTask.java
相关文章


![[.NET] 一步步打造一个简单的 MVC 电商网站 - BooksStore(三) - 反骨仔(二五仔)](/upload8/allimg/170402/1100395518_lit.png)
精彩导读
热门资讯
关注我们