| | |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.nq.common.ServerResponse; |
| | | import com.nq.dao.SiteNewsMapper; |
| | | import com.nq.enums.EStockType; |
| | | import com.nq.pojo.SiteNews; |
| | | import com.nq.service.ISiteNewsService; |
| | | import com.nq.utils.*; |
| | |
| | | // 创建固定大小的线程池,根据需求调整线程数量 |
| | | ExecutorService executor = Executors.newFixedThreadPool(2); |
| | | try { |
| | | // 提交美国新闻抓取任务 |
| | | // 提交新闻抓取任务 |
| | | executor.submit(() -> |
| | | addNews(1, PropertiesUtil.getProperty("US_HTTP_API") + "stock-markets?key=" + PropertiesUtil.getProperty("US_KEY") + "&type=1") |
| | | ); |
| | | // 提交墨西哥新闻抓取任务 |
| | | executor.submit(() -> |
| | | addNews(1, PropertiesUtil.getProperty("MX_HTTP_API") + "stock-markets?key=" + PropertiesUtil.getProperty("MX_KEY") + "&type=1") |
| | | addNews(1, PropertiesUtil.getProperty("JP_HTTP_API") + "stock-markets?key=" + PropertiesUtil.getProperty("JP_KEY") + "&type=1") |
| | | ); |
| | | } finally { |
| | | // 关闭线程池 |