java循环执行程序在一定时间后停止

时间:2015-09-15 12:00:53

标签: java multithreading bash infinite-loop execution

public Test(){}


public void run() {
    System.out.println("calls");

    Map<String, Indexation> mi = new HashMap<>();
    String[] spl = compo.split("[\\s@&.?$+-:_!^{}']+");


    int ct = 0;

    try {
        System.out.println("calls Prep");
        PreparedStatement p = GetConnexion.getPST("select * from mtg where ogvideo is null and title!=? and alfa!=? and st=? order by id desc limit 1");
        PreparedStatement pu = GetConnexion.getPST("update mtg set st=? where id=?");
        p.setString(1, "");
        p.setString(2, "");
        p.setInt(3, 0);
        ResultSet r = p.executeQuery();
        while (r.next()) {

            int id = r.getInt("id");
            pu.setInt(1, 2);
            pu.setInt(2, id);
            pu.executeUpdate();
            System.out.println(id + "--------");
            String title = r.getString("title");
            String alfa = r.getString("alfa");
            String compo = title + " " + alfa;
            String url = r.getString("url");
            compo = compo.toLowerCase();
            String[] spl = compo.split("[.=#&,;x|<>!\\s\\-:_\\?\\p{P} \\t\\n\\r]+");

            System.out.println("<--->");
            for (String s : spl) {
                System.out.println("+++++++++++++");
                ct = getFrequencies(spl, s) + getOccu(url, s);
                System.out.println("----coll----");
                Indexation i = new Indexation(alfa, title, url, ct, s,
                        s + url);
                if (s.length() > 2 &&
                        !getAllStpW().contains(s) &&
                        !getDirty().contains(s)) mi.put(s, i);
            }

        }
        r.close();
        p.close();
        System.out.println("end");
    } catch (Exception f) {
        f.printStackTrace();
    }
}

上面的程序是我从Thread继承的Test.java。 我想在linux服务器中一直循环执行它, 这是bash脚本:test.sh

while true 
do
java -Xms40m -Xmx712m -verbose:gc  -jar test.jar

完成

脚本的执行没有任何例外,但在一定时间后停止并显示表的ID和消息+++++++++++++++++ 我这个问题很长一段时间了。我说服每次都杀死应用程序的进程ID!

我该怎么办?

0 个答案:

没有答案