HM0001TestThread.java 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package com.miniframe.comm.httpclientapater;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import org.apache.log4j.Logger;
  5. import com.miniframe.comm.httpclientapater.HttpclientapaterUtil;
  6. import com.miniframe.generate.comm.system.A_HM0001;
  7. import com.miniframe.generate.comm.httpclientapater.HM0001Client;
  8. import com.miniframe.generate.business.system.model.HM0001BaseModel;
  9. public class HM0001TestThread implements Runnable{
  10. private static final Logger logger = Logger.getLogger(HM0001TestThread.class);
  11. /**
  12. * 系统登录,获取报文体
  13. * @return
  14. */
  15. public static A_HM0001 getA_hm0001() {
  16. A_HM0001 a_hm0001 = new A_HM0001();
  17. // ----------以下增加【系统登录】上行体赋值-------------
  18. a_hm0001.setLogintype("1");
  19. a_hm0001.setPassword("2176216712");
  20. a_hm0001.setVerifygraph("1234");
  21. // ---------------------------------------------------
  22. return a_hm0001;
  23. }
  24. /**
  25. * 运行客户端测试,系统登录
  26. *
  27. * @param args
  28. * @throws Exception
  29. */
  30. public static void main(String[] args) throws Exception {
  31. List<Thread> list = new ArrayList<Thread>();
  32. for(int i=0;i<200;i++) {
  33. HM0001TestThread test = new HM0001TestThread();
  34. Thread thread1 = new Thread(test);
  35. list.add(thread1);
  36. }
  37. for(int i=0;i<200;i++) {
  38. Thread thread1 = (Thread) list.get(i);
  39. thread1.start();
  40. }
  41. }
  42. @Override
  43. public void run() {
  44. HM0001BaseModel model = new HM0001BaseModel();
  45. model.setA_systemhead(HttpclientapaterUtil.getA_systemhead("HM0001"));
  46. model.setA_hm0001(HM0001TestThread.getA_hm0001());
  47. HM0001Client client = new HM0001Client();
  48. while(true) {
  49. //logger.error("客户端发送前总线:\r\n"+model);
  50. try {
  51. model = client.execute(model);
  52. } catch (Exception e) {
  53. e.printStackTrace();
  54. }
  55. //logger.error("客户端发送后总线:\r\n"+model);
  56. //Thread.sleep(1);
  57. logger.error(Thread.currentThread().getId());
  58. }
  59. }
  60. }