java开启多线程执行延时操作

天涯浪子 提交于 2020-02-10 18:49:55
//删除之前的信息
            if (count > 0) {
                // 多线程处理
                new Thread() {
                    @SuppressWarnings("unchecked")
                    public void run() {
                        int num = 0;
                        Map<String, String> map = null;
                        String sql = "update user set status=1 where id=? ";
                        //三分钟
                        while (num < 90) {
                            try {
                                Thread.sleep(2000);
                            } catch (InterruptedException e) {
                                e.printStackTrace();
                            }
                            for (String item : listOrderId) {
                                SqlMapExe.executeUpdate(sql, new String[]{item});
                                logger.info("########################多线程执行SQL:" + sql + "参数:" + item + "################################end");
                            }
                            num++;
                        }
                    }
                }.start();
            }

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!