Main.java 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package com.uas.main;
  2. import com.uas.util.BaseUtil;
  3. import com.uas.util.JdbcUtil;
  4. import static com.uas.main.Upload.*;
  5. public class Main {
  6. public static void main(String[] args) {
  7. final long timeInterval =5*60*1000;
  8. Runnable runnable = new Runnable() {
  9. public void run() {
  10. while (true) {
  11. // ------- code for task to run
  12. a();
  13. // ------- ends here
  14. try {
  15. Thread.sleep(timeInterval);
  16. } catch (InterruptedException e) {
  17. e.printStackTrace();
  18. }
  19. }
  20. }
  21. };
  22. Thread thread = new Thread(runnable);
  23. thread.start();
  24. }
  25. public static void a() {
  26. run();
  27. System.out.println("begin");
  28. Download.run();
  29. try{ //关闭数据库连接
  30. if(JdbcUtil.connection!=null){
  31. JdbcUtil.connection.close();
  32. }
  33. }catch(Exception e){
  34. BaseUtil.getLogger().error(e.toString());
  35. e.printStackTrace();
  36. }finally{
  37. JdbcUtil.connection = null;
  38. }
  39. System.out.println("run over!");
  40. }
  41. }