CommonMailThread.java 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /**
  2. * @(#)file SignThread.java
  3. * @(#)author DaeJin Lee
  4. * @(#)version 1.0
  5. * @(#)date Jun 10, 2005
  6. * @(#)since JDK 1.4.2
  7. *
  8. * Copyright (c) www.dcchem.co.kr, Inc.
  9. * All rights reserved.
  10. * This software is the proprietary information of dcchem, Inc.
  11. */
  12. package kr.co.udapsoft.common.commonSign;
  13. import kr.co.hsnc.common.logger.Logger;
  14. /**
  15. *
  16. * @version 1.0
  17. * @author DaeJin Lee
  18. */
  19. public class CommonMailThread extends Thread {
  20. private boolean IS_RUN = false;
  21. //1000l * 120 * 1 2분주기
  22. private long INTERVAL = 1000l * 120 * 1 ; //1000l * 60 * 60 * 1 1시간에 한번. 오전09:00 실행
  23. private static CommonMailThreadBiz biz = null;
  24. protected CommonMailThread() {
  25. biz = new CommonMailThreadBiz();
  26. }
  27. /**
  28. * Thread 가동여부를 리턴
  29. * @return
  30. */
  31. public boolean isRun() {
  32. return this.IS_RUN;
  33. }
  34. /**
  35. * Thread Start
  36. */
  37. public void doStart() {
  38. if( !this.IS_RUN ) {
  39. this.IS_RUN = true;
  40. this.start();
  41. }
  42. }
  43. /**
  44. * Thread Stop
  45. */
  46. public void doStop() {
  47. if( this.IS_RUN ) {
  48. this.IS_RUN = false;
  49. super.interrupt();
  50. }
  51. }
  52. /* (non-Javadoc)
  53. * @see java.lang.Runnable#run()
  54. */
  55. public void run() {
  56. while(IS_RUN) {
  57. try {
  58. Thread.sleep(INTERVAL);
  59. }
  60. catch(InterruptedException ie) {
  61. }
  62. try {
  63. if( IS_RUN ) {
  64. Logger.debug.println("hwenc.common.commonSign.CommonMailThread run.");
  65. biz.doBiz();
  66. }
  67. }
  68. catch(Exception e) {
  69. e.printStackTrace(System.out);
  70. Logger.err.printStackTrace(e);
  71. }
  72. }
  73. }
  74. }