java高并发
业务场景:一般在项目完成时,为了项目的稳定性,安全性,我们一般都会做一个测试工具,就比如高并发测试:在一个时间点同时访问莫一个服务
需要知道的几个知识点:
1)AtomicInteger
AtomicInteger提供原子操作来进行Integer的使用,因此十分适合高并发情况下的使用,在a线程中+1,此时在b线程中在看这个值就是+1后的值了
参考:https://www.cnblogs.com/zhaoyan001/p/8885360.html
2)ExecutorService
线程池
3)CountDownLatch
正如每个Java文档所描述的那样,CountDownLatch是一个同步工具类,它允许一个或多个线程一直等待,直到其他线程的操作执行完后再执行
http://www.importnew.com/15731.html
4)例子:
public Result highlyConcurrentTest1(Integer count,String classes) {Date data = new Date();
Map<Thread,HttpURLConnection> threadData = new HashMap<Thread,HttpURLConnection>();
final AtomicInteger number = new AtomicInteger(); //计数执行失败的线程
ExecutorService pool = Executors.newCachedThreadPool(); //创建一个线程池
final CountDownLatch cdOrder = new CountDownLatch(1);//指挥官的命令,设置为1,指挥官一下达命令,则cutDown,变为0,战士们执行任务
final CountDownLatch cdAnswer = new CountDownLatch(count-1);//因为有三个战士,所以初始值为count,每一个战士执行任务完毕则cutDown一次,当三个都执行完毕,变为0,则指挥官停止等待。
Runnable runnable = new Runnable() {
@Override
public void run() {
try {
log.info("子线程"+Thread.currentThread().getName()+"正准备执行");
cdOrder.await();//战士们都处于等待命令状态
synchronized (this) {
switch (classes) {
case "8881":
String endPoint1 = "http://"+testIp+":8881/WebSiteSouthRJ/CSWebService.asmx";
HttpURLConnection connection1 = SoapUtil.invokeSrvGet(endPoint1);
threadData.put(Thread.currentThread(), connection1);
break;
case "8882":
String soapXML17 = "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Body><ESP_Input xmlns=\"http://tempuri.org/\"><user>RuiKe</user><password>eea79c4e7f1c453d866bcb0bbd22138e</password><methodCode>EMR-ET-S10</methodCode><methodName>SynchRisReport</methodName><parameter><CallInfo><Reportcomment><ETONo>8185856</ETONo><ETODetailNo>9305395</ETODetailNo><ReportNo>c8293bac-03bb-4879-9b9c-0d3fa10ddd74</ReportNo><ExamDateTime></ExamDateTime><ReportDateTime>2018-08-21 16:32:59</ReportDateTime><ExamPart>胸部平扫</ExamPart><DeptCode>33620562</DeptCode><DeptName>33620562</DeptName><DoctorId>1135</DoctorId><DoctorName>1135</DoctorName><CriticalFlag>0</CriticalFlag><CriticalContent></CriticalContent><ExamDescript>行aaaa1\r\n行aaaa2\r\n行aaaa3\r\n行4aaaa</ExamDescript><DiagDescript></DiagDescript><ExamVerdict>结果1\r\n结果2\r\n结果3\r\n</ExamVerdict><ExamDiag></ExamDiag><Reporter>zww</Reporter><ReporterName>zww</ReporterName><DateTime></DateTime><ReportTypeFlag>1</ReportTypeFlag><Noter></Noter><ReportURL></ReportURL><ImageURL><![CDATA[http://172.26.12.37/masterview/mv.jsp?server_name=pacsrjnFIR&user_name=clinic&close_on_exit=true&key_images=false&password=clinic&accession_number=CT9008185856]]></ImageURL></Reportcomment></CallInfo></parameter></ESP_Input></soap:Body></soap:Envelope>";
String endPoint17 = "http://"+testIp+":8882/MedicalServiceESB.asmx";
String soapAction17 = "http://tempuri.org/ESP_Input";
HttpURLConnection connection2 = SoapUtil.invokeSrvSoap(endPoint17,soapAction17, soapXML17);
threadData.put(Thread.currentThread(), connection2);
break;
case "8883":
String endPoint3 = "http://"+testIp+":8883/WebSiteSouthRJ/CSWebService.asmx?WSDL";
HttpURLConnection connection3 = SoapUtil.invokeSrvGet(endPoint3);
threadData.put(Thread.currentThread(), connection3);
break;
case "8884":
String soapXML4 = "<?xml version=\"1.0\"?>\r\n"+
"<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><SOAP-ENV:Body><ESP_Input xmlns=\"http://tempuri.org/\"><user></user><password></password><methodCode>EMR-ET-S10</methodCode><methodName>SynchRisReport</methodName><parameter><?xml version='1.0' encoding='utf-8'?><CallInfo><Reportcomment><ETONo>12400537</ETONo><ETODetailNo>12400537</ETODetailNo><ReportNo>1</ReportNo><ExamDateTime>2018-10-24 13:45:46</ExamDateTime><ReportDateTime>2018-10-24 13:45:46</ReportDateTime><ExamPart>颈动脉</ExamPart><DeptCode>33670262</DeptCode><DeptName>超声医学科</DeptName><DoctorId></DoctorId><DoctorName>蒋会</DoctorName><CriticalFlag>1</CriticalFlag><CriticalContent></CriticalContent><ExamDescript>右侧颈总��脉内径5.3mm,内膜中层厚度1.3mm,最大流速87cm/s,舒张末期流速21cm/s,阻力指数0.78。&#13;&#10;左侧颈总动脉内径5.2mm,内膜中层厚度1.2mm,最大流速89cm/s,舒张末期流速20cm/s,阻力指数0.78。&#13;&#10;右侧颈动脉分叉处内膜中层厚度:0.9-1.5mm。&#13;&#10;左侧颈动脉分叉处内膜中层厚度:0.9-1.4mm。&#13;&#10;\r\n"+
"右侧颈内动脉内径4.8mm,内膜中层厚度0.5mm,最大流速78cm/s,舒张末期流速21cm/s,阻力指数0.65。&#13;&#10;右侧颈外动脉内径3.9mm,内膜中层厚度0.5mm,最大流速60cm/s,舒张末期流速14cm/s,阻力指数0.78。&#13;&#10;左侧颈内动脉内径4.6mm,内膜中层厚度0.5mm,最大流速77cm/s,舒张末期流速20cm/s,阻力指数0.66。&#13;&#10;左侧颈外动脉内径3.5mm,内膜中层厚度0.5mm,最大流速65cm/s,舒张末期流速12cm/s,阻力指数0.79。&#13;&#10;双侧颈动脉内膜面毛糙,双侧颈动脉分叉处内膜中层不规则增厚伴强回声斑块,左侧大小约3.7*0.9mm。&#13;&#10;</ExamDescript><DiagDescript></DiagDescript><ExamVerdict>双侧颈动脉内膜面毛糙,双侧颈动脉分叉处内膜中层不规则增厚伴钙化灶形成&#13;&#10;</ExamVerdict><ExamDiag></ExamDiag><Reporter></Reporter><ReporterName>蒋会</ReporterName><DateTime>2018-10-24 13:45:46</DateTime><ReportTypeFlag>1</ReportTypeFlag><Noter>"+
"</Noter><ReportURL>http://172.26.12.39:81/HCRISOtherReport.aspx?Patient_ID=377579</ReportURL><ImageURL>377579</ImageURL></Reportcomment></CallInfo></parameter></ESP_Input></SOAP-ENV:Body></SOAP-ENV:Envelope>";
String soapXML14 = "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Body><ESP_Input xmlns=\"http://tempuri.org/\"><user>RuiKe</user><password>eea79c4e7f1c453d866bcb0bbd22138e</password><methodCode>EMR-ET-S02</methodCode><methodName>SynchReceiveInfo</methodName><parameter><CallInfo><ETONo>9690890</ETONo><ETODetailNo>10898322</ETODetailNo><PerformedBy>33620362</PerformedBy><Technician>RIS</Technician><StatusFlag>1</StatusFlag><SysFlag>1</SysFlag></CallInfo> </parameter></ESP_Input></soap:Body></soap:Envelope>";
String endPoint4 = "http://"+testIp+":8884/MedicalServiceESB.asmx";
String soapAction4 = "http://tempuri.org/ESP_Input";
HttpURLConnection connection4 = SoapUtil.invokeSrvSoap(endPoint4,soapAction4, soapXML4);
threadData.put(Thread.currentThread(), connection4);
break;
case "8885":
String endPoint5 = "http://"+testIp+":8885/WebSiteSouthRJ/CSWebService.asmx?WSDL";
HttpURLConnection connection5 = SoapUtil.invokeSrvGet(endPoint5);
threadData.put(Thread.currentThread(), connection5);
break;
case "8886":
java.util.Random random=new java.util.Random();
int result=random.nextInt(4);
String soapXML6="";
String endPoint6 = "";
String soapAction6 = "";
switch(result){
case 0:
soapXML6="<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:zs1=\"http://tempuri.org/\"> <s:Body> <zs1:SynchLisReportStatusByReportNo> <zs1:ReportNo><![CDATA[5404720]]></zs1:ReportNo> <zs1:ETONo><![CDATA[11235151]]></zs1:ETONo> <zs1:PerformedBy><![CDATA[33600262]]></zs1:PerformedBy> <zs1:Technician><![CDATA[017040]]></zs1:Technician> <zs1:StatusFlag><![CDATA[1]]></zs1:StatusFlag> <zs1:SysFlag><![CDATA[1]]></zs1:SysFlag> </zs1:SynchLisReportStatusByReportNo > </s:Body></s:Envelope>";
endPoint6="http://"+testIp+":8886/InspectService.asmx";
soapAction6="http://tempuri.org/SynchLisReportStatusByReportNo";
break;
case 1:
soapXML6="<E:Envelope xmlns:E=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:A=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:y=\"http://www.w3.org/2001/XMLSchema\" E:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><E:Body><m:SynchBloodFeeInfo xmlns:m=\"http://tempuri.org/LIS/\"><m:Barcode s:type=\"y:string\">BX1000041165</m:Barcode><m:FeeInfo s:type=\"y:string\"><FeeInfo>
 <Record>
 <OrderId>14978220</OrderId>
 <DetailXh>0</DetailXh>
 <ChargeItemId>X0000-2</ChargeItemId>
 <ItemFlag>1</ItemFlag>
 <Count>2.00</Count>
 <ModifyDate>2018-06-25 18:14:28</ModifyDate>
 <ModifyStaffId>012610</ModifyStaffId>
 <ModifyDeptId>33780012</ModifyDeptId>
 </Record>
</FeeInfo></m:FeeInfo></m:SynchBloodFeeInfo></E:Body></E:Envelope>";
endPoint6="http://"+testIp+":8886/InspectServiceESB.asmx";
soapAction6="http://tempuri.org/LIS/SynchBloodFeeInfo";
break;
case 2:
soapXML6="<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Body><CreateLisReport xmlns=\"http://tempuri.org/\"><REPORTCOMMENT> <Report> <ReportHead> <ETO_NO>S018062508543</ETO_NO> <ETO_DETAIL_NO>12472213</ETO_DETAIL_NO> <REPORT_NO>LIS5404720</REPORT_NO> <EXAM_DATE_TIME>2018062518:11:02</EXAM_DATE_TIME> <REPORT_DATE_TIME>2018062518:20:35</REPORT_DATE_TIME> <DEPT_CODE></DEPT_CODE> <DEPT_NAME></DEPT_NAME> <DOCTOR_ID>7040</DOCTOR_ID> <DOCTOR_NAME>蔡回波</DOCTOR_NAME> <CRITICAL>0</CRITICAL> <DESCRIPTION></DESCRIPTION> <REPORTER>2401</REPORTER> <REPORTER_NAME>袁挺</REPORTER_NAME> <DESCRIPTION_DATE_TIME>2018062518:11:02</DESCRIPTION_DATE_TIME> <DETAIL></DETAIL> <REPORT_TYPE>0</REPORT_TYPE> <SAMPLEKIND>静脉血</SAMPLEKIND> </ReportHead> <ReportDetail> <REPORT_NO>LIS5404720</REPORT_NO> <VISIT_ID>4589010</VISIT_ID> <REPORT_TYPE>LIS</REPORT_TYPE> <REPORT_TYPE_NAME></REPORT_TYPE_NAME> <ITEM_CODE>pH</ITEM_CODE> <ITEM_NAME>PH值</ITEM_NAME> <RELEVANT_LAB_TEST>7.37</RELEVANT_LAB_TEST> <ITEM_EXTRAVALUE></ITEM_EXTRAVALUE> <DEPT_CODE></DEPT_CODE> <DEPT_NAME></DEPT_NAME> <REPORTER>7040</REPORTER> <REPORTER_NAME>蔡回波</REPORTER_NAME> <DATE_TIME>2018062518:11:02</DATE_TIME> <ITEM_UP></ITEM_UP> <ITEM_DOWN></ITEM_DOWN> <ITEM_UNIT></ITEM_UNIT> <ITEM_STATUS>M</ITEM_STATUS> <CRITICALMINBAND></CRITICALMINBAND> <CRITICALMAXBAND></CRITICALMAXBAND> <CRITICALFLAG>0</CRITICALFLAG> <CRITICALREPLYFLAG></CRITICALREPLYFLAG> <ITEM_EXAMMETHOD></ITEM_EXAMMETHOD> <RELATED_ITEM_CODE></RELATED_ITEM_CODE> <BANDRANGE>7.35--7.45</BANDRANGE> </ReportDetail> <ReportDetail> <REPORT_NO>LIS5404720</REPORT_NO> <VISIT_ID></VISIT_ID> <REPORT_TYPE>LIS</REPORT_TYPE> <REPORT_TYPE_NAME></REPORT_TYPE_NAME> <ITEM_CODE>pCO2</ITEM_CODE> <ITEM_NAME>二氧化碳分压</ITEM_NAME> <RELEVANT_LAB_TEST>46</RELEVANT_LAB_TEST> <ITEM_EXTRAVALUE></ITEM_EXTRAVALUE> <DEPT_CODE></DEPT_CODE> <DEPT_NAME></DEPT_NAME> <REPORTER></REPORTER> <REPORTER_NAME></REPORTER_NAME> <DATE_TIME></DATE_TIME> <ITEM_UP></ITEM_UP> <ITEM_DOWN></ITEM_DOWN> <ITEM_UNIT>mmHg</ITEM_UNIT> <ITEM_STATUS>M</ITEM_STATUS> <CRITICALMINBAND></CRITICALMINBAND> <CRITICALMAXBAND></CRITICALMAXBAND> <CRITICALFLAG>0</CRITICALFLAG> <CRITICALREPLYFLAG></CRITICALREPLYFLAG> <ITEM_EXAMMETHOD></ITEM_EXAMMETHOD> <RELATED_ITEM_CODE></RELATED_ITEM_CODE> <BANDRANGE></BANDRANGE> </ReportDetail> <ReportDetail> <REPORT_NO>LIS5404720</REPORT_NO> <VISIT_ID></VISIT_ID> <REPORT_TYPE>LIS</REPORT_TYPE> <REPORT_TYPE_NAME></REPORT_TYPE_NAME> <ITEM_CODE>pO2</ITEM_CODE> <ITEM_NAME>氧分压</ITEM_NAME> <RELEVANT_LAB_TEST>25</RELEVANT_LAB_TEST> <ITEM_EXTRAVALUE></ITEM_EXTRAVALUE> <DEPT_CODE></DEPT_CODE> <DEPT_NAME></DEPT_NAME> <REPORTER></REPORTER> <REPORTER_NAME></REPORTER_NAME> <DATE_TIME></DATE_TIME> <ITEM_UP></ITEM_UP> <ITEM_DOWN></ITEM_DOWN> <ITEM_UNIT>mmHg</ITEM_UNIT> <ITEM_STATUS>M</ITEM_STATUS> <CRITICALMINBAND></CRITICALMINBAND> <CRITICALMAXBAND></CRITICALMAXBAND> <CRITICALFLAG>0</CRITICALFLAG> <CRITICALREPLYFLAG></CRITICALREPLYFLAG> <ITEM_EXAMMETHOD></ITEM_EXAMMETHOD> <RELATED_ITEM_CODE></RELATED_ITEM_CODE> <BANDRANGE></BANDRANGE> </ReportDetail> <ReportDetail> <REPORT_NO>LIS5404720</REPORT_NO> <VISIT_ID></VISIT_ID> <REPORT_TYPE>LIS</REPORT_TYPE> <REPORT_TYPE_NAME></REPORT_TYPE_NAME> <ITEM_CODE>SO2c</ITEM_CODE> <ITEM_NAME>氧饱和度</ITEM_NAME> <RELEVANT_LAB_TEST>43</RELEVANT_LAB_TEST> <ITEM_EXTRAVALUE></ITEM_EXTRAVALUE> <DEPT_CODE></DEPT_CODE> <DEPT_NAME></DEPT_NAME> <REPORTER></REPORTER> <REPORTER_NAME></REPORTER_NAME> <DATE_TIME></DATE_TIME> <ITEM_UP></ITEM_UP> <ITEM_DOWN></ITEM_DOWN> <ITEM_UNIT>%</ITEM_UNIT> <ITEM_STATUS>M</ITEM_STATUS> <CRITICALMINBAND></CRITICALMINBAND> <CRITICALMAXBAND></CRITICALMAXBAND> <CRITICALFLAG>0</CRITICALFLAG> <CRITICALREPLYFLAG></CRITICALREPLYFLAG> <ITEM_EXAMMETHOD></ITEM_EXAMMETHOD> <RELATED_ITEM_CODE></RELATED_ITEM_CODE> <BANDRANGE></BANDRANGE> </ReportDetail> <ReportDetail> <REPORT_NO>LIS5404720</REPORT_NO> <VISIT_ID></VISIT_ID> <REPORT_TYPE>LIS</REPORT_TYPE> <REPORT_TYPE_NAME></REPORT_TYPE_NAME> <ITEM_CODE>TCO2</ITEM_CODE> <ITEM_NAME>二氧化碳总量</ITEM_NAME> <RELEVANT_LAB_TEST>28.0</RELEVANT_LAB_TEST> <ITEM_EXTRAVALUE></ITEM_EXTRAVALUE> <DEPT_CODE></DEPT_CODE> <DEPT_NAME></DEPT_NAME> <REPORTER></REPORTER> <REPORTER_NAME></REPORTER_NAME> <DATE_TIME></DATE_TIME> <ITEM_UP></ITEM_UP> <ITEM_DOWN></ITEM_DOWN> <ITEM_UNIT>mmol/L</ITEM_UNIT> <ITEM_STATUS>M</ITEM_STATUS> <CRITICALMINBAND></CRITICALMINBAND> <CRITICALMAXBAND></CRITICALMAXBAND> <CRITICALFLAG>0</CRITICALFLAG> <CRITICALREPLYFLAG></CRITICALREPLYFLAG> <ITEM_EXAMMETHOD></ITEM_EXAMMETHOD> <RELATED_ITEM_CODE></RELATED_ITEM_CODE> <BANDRANGE>24--32</BANDRANGE> </ReportDetail> <ReportDetail> <REPORT_NO>LIS5404720</REPORT_NO> <VISIT_ID></VISIT_ID> <REPORT_TYPE>LIS</REPORT_TYPE> <REPORT_TYPE_NAME></REPORT_TYPE_NAME> <ITEM_CODE>Na+</ITEM_CODE> <ITEM_NAME>钠</ITEM_NAME> <RELEVANT_LAB_TEST>141</RELEVANT_LAB_TEST> <ITEM_EXTRAVALUE></ITEM_EXTRAVALUE> <DEPT_CODE></DEPT_CODE> <DEPT_NAME></DEPT_NAME> <REPORTER></REPORTER> <REPORTER_NAME></REPORTER_NAME> <DATE_TIME></DATE_TIME> <ITEM_UP></ITEM_UP> <ITEM_DOWN></ITEM_DOWN> <ITEM_UNIT>mmol/L</ITEM_UNIT> <ITEM_STATUS>M</ITEM_STATUS> <CRITICALMINBAND></CRITICALMINBAND> <CRITICALMAXBAND></CRITICALMAXBAND> <CRITICALFLAG>0</CRITICALFLAG> <CRITICALREPLYFLAG></CRITICALREPLYFLAG> <ITEM_EXAMMETHOD></ITEM_EXAMMETHOD> <RELATED_ITEM_CODE></RELATED_ITEM_CODE> <BANDRANGE>135--145</BANDRANGE> </ReportDetail> <ReportDetail> <REPORT_NO>LIS5404720</REPORT_NO> <VISIT_ID></VISIT_ID> <REPORT_TYPE>LIS</REPORT_TYPE> <REPORT_TYPE_NAME></REPORT_TYPE_NAME> <ITEM_CODE>K+</ITEM_CODE> <ITEM_NAME>钾</ITEM_NAME> <RELEVANT_LAB_TEST>3.8</RELEVANT_LAB_TEST> <ITEM_EXTRAVALUE></ITEM_EXTRAVALUE> <DEPT_CODE></DEPT_CODE> <DEPT_NAME></DEPT_NAME> <REPORTER></REPORTER> <REPORTER_NAME></REPORTER_NAME> <DATE_TIME></DATE_TIME> <ITEM_UP></ITEM_UP> <ITEM_DOWN></ITEM_DOWN> <ITEM_UNIT>mmol/L</ITEM_UNIT> <ITEM_STATUS>M</ITEM_STATUS> <CRITICALMINBAND></CRITICALMINBAND> <CRITICALMAXBAND></CRITICALMAXBAND> <CRITICALFLAG>0</CRITICALFLAG> <CRITICALREPLYFLAG></CRITICALREPLYFLAG> <ITEM_EXAMMETHOD></ITEM_EXAMMETHOD> <RELATED_ITEM_CODE></RELATED_ITEM_CODE> <BANDRANGE>3.5--5.5</BANDRANGE> </ReportDetail> <ReportDetail> <REPORT_NO>LIS5404720</REPORT_NO> <VISIT_ID></VISIT_ID> <REPORT_TYPE>LIS</REPORT_TYPE> <REPORT_TYPE_NAME></REPORT_TYPE_NAME> <ITEM_CODE>Ca++</ITEM_CODE> <ITEM_NAME>离子钙</ITEM_NAME> <RELEVANT_LAB_TEST>1.13</RELEVANT_LAB_TEST> <ITEM_EXTRAVALUE></ITEM_EXTRAVALUE> <DEPT_CODE></DEPT_CODE> <DEPT_NAME></DEPT_NAME> <REPORTER></REPORTER> <REPORTER_NAME></REPORTER_NAME> <DATE_TIME></DATE_TIME> <ITEM_UP></ITEM_UP> <ITEM_DOWN></ITEM_DOWN> <ITEM_UNIT>mmol/L</ITEM_UNIT> <ITEM_STATUS>L</ITEM_STATUS> <CRITICALMINBAND></CRITICALMINBAND> <CRITICALMAXBAND></CRITICALMAXBAND> <CRITICALFLAG>0</CRITICALFLAG> <CRITICALREPLYFLAG></CRITICALREPLYFLAG> <ITEM_EXAMMETHOD></ITEM_EXAMMETHOD> <RELATED_ITEM_CODE></RELATED_ITEM_CODE> <BANDRANGE>1.15--1.27</BANDRANGE> </ReportDetail> <ReportDetail> <REPORT_NO>LIS5404720</REPORT_NO> <VISIT_ID></VISIT_ID> <REPORT_TYPE>LIS</REPORT_TYPE> <REPORT_TYPE_NAME></REPORT_TYPE_NAME> <ITEM_CODE>Lac</ITEM_CODE> <ITEM_NAME>乳酸</ITEM_NAME> <RELEVANT_LAB_TEST>1.2</RELEVANT_LAB_TEST> <ITEM_EXTRAVALUE></ITEM_EXTRAVALUE> <DEPT_CODE></DEPT_CODE> <DEPT_NAME></DEPT_NAME> <REPORTER></REPORTER> <REPORTER_NAME></REPORTER_NAME> <DATE_TIME></DATE_TIME> <ITEM_UP></ITEM_UP> <ITEM_DOWN></ITEM_DOWN> <ITEM_UNIT>mmol/L</ITEM_UNIT> <ITEM_STATUS>M</ITEM_STATUS> <CRITICALMINBAND></CRITICALMINBAND> <CRITICALMAXBAND></CRITICALMAXBAND> <CRITICALFLAG>0</CRITICALFLAG> <CRITICALREPLYFLAG></CRITICALREPLYFLAG> <ITEM_EXAMMETHOD></ITEM_EXAMMETHOD> <RELATED_ITEM_CODE></RELATED_ITEM_CODE> <BANDRANGE>0.5--2.2</BANDRANGE> </ReportDetail> <ReportDetail> <REPORT_NO>LIS5404720</REPORT_NO> <VISIT_ID></VISIT_ID> <REPORT_TYPE>LIS</REPORT_TYPE> <REPORT_TYPE_NAME></REPORT_TYPE_NAME> <ITEM_CODE>Hct</ITEM_CODE> <ITEM_NAME>红细胞压积</ITEM_NAME> <RELEVANT_LAB_TEST>53</RELEVANT_LAB_TEST> <ITEM_EXTRAVALUE></ITEM_EXTRAVALUE> <DEPT_CODE></DEPT_CODE> <DEPT_NAME></DEPT_NAME> <REPORTER></REPORTER> <REPORTER_NAME></REPORTER_NAME> <DATE_TIME></DATE_TIME> <ITEM_UP></ITEM_UP> <ITEM_DOWN></ITEM_DOWN> <ITEM_UNIT>%</ITEM_UNIT> <ITEM_STATUS>H</ITEM_STATUS> <CRITICALMINBAND></CRITICALMINBAND> <CRITICALMAXBAND></CRITICALMAXBAND> <CRITICALFLAG>0</CRITICALFLAG> <CRITICALREPLYFLAG></CRITICALREPLYFLAG> <ITEM_EXAMMETHOD></ITEM_EXAMMETHOD> <RELATED_ITEM_CODE></RELATED_ITEM_CODE> <BANDRANGE>33--51</BANDRANGE> </ReportDetail> <ReportDetail> <REPORT_NO>LIS5404720</REPORT_NO> <VISIT_ID></VISIT_ID> <REPORT_TYPE>LIS</REPORT_TYPE> <REPORT_TYPE_NAME></REPORT_TYPE_NAME> <ITEM_CODE>HCO3-</ITEM_CODE> <ITEM_NAME>碳酸氢根</ITEM_NAME> <RELEVANT_LAB_TEST>26.6</RELEVANT_LAB_TEST> <ITEM_EXTRAVALUE></ITEM_EXTRAVALUE> <DEPT_CODE></DEPT_CODE> <DEPT_NAME></DEPT_NAME> <REPORTER></REPORTER> <REPORTER_NAME></REPORTER_NAME> <DATE_TIME></DATE_TIME> <ITEM_UP></ITEM_UP> <ITEM_DOWN></ITEM_DOWN> <ITEM_UNIT>mmol/L</ITEM_UNIT> <ITEM_STATUS>M</ITEM_STATUS> <CRITICALMINBAND></CRITICALMINBAND> <CRITICALMAXBAND></CRITICALMAXBAND> <CRITICALFLAG>0</CRITICALFLAG> <CRITICALREPLYFLAG></CRITICALREPLYFLAG> <ITEM_EXAMMETHOD></ITEM_EXAMMETHOD> <RELATED_ITEM_CODE></RELATED_ITEM_CODE> <BANDRANGE>22--29</BANDRANGE> </ReportDetail> <ReportDetail> <REPORT_NO>LIS5404720</REPORT_NO> <VISIT_ID></VISIT_ID> <REPORT_TYPE>LIS</REPORT_TYPE> <REPORT_TYPE_NAME></REPORT_TYPE_NAME> <ITEM_CODE>HCO3std</ITEM_CODE> <ITEM_NAME>标准碳酸氢根</ITEM_NAME> <RELEVANT_LAB_TEST>23.7</RELEVANT_LAB_TEST> <ITEM_EXTRAVALUE></ITEM_EXTRAVALUE> <DEPT_CODE></DEPT_CODE> <DEPT_NAME></DEPT_NAME> <REPORTER></REPORTER> <REPORTER_NAME></REPORTER_NAME> <DATE_TIME></DATE_TIME> <ITEM_UP></ITEM_UP> <ITEM_DOWN></ITEM_DOWN> <ITEM_UNIT>mmol/L</ITEM_UNIT> <ITEM_STATUS>M</ITEM_STATUS> <CRITICALMINBAND></CRITICALMINBAND> <CRITICALMAXBAND></CRITICALMAXBAND> <CRITICALFLAG>0</CRITICALFLAG> <CRITICALREPLYFLAG></CRITICALREPLYFLAG> <ITEM_EXAMMETHOD></ITEM_EXAMMETHOD> <RELATED_ITEM_CODE></RELATED_ITEM_CODE> <BANDRANGE>22--29</BANDRANGE> </ReportDetail> <ReportDetail> <REPORT_NO>LIS5404720</REPORT_NO> <VISIT_ID></VISIT_ID> <REPORT_TYPE>LIS</REPORT_TYPE> <REPORT_TYPE_NAME></REPORT_TYPE_NAME> <ITEM_CODE>BE(B)</ITEM_CODE> <ITEM_NAME>全血剩余碱</ITEM_NAME> <RELEVANT_LAB_TEST>0.7</RELEVANT_LAB_TEST> <ITEM_EXTRAVALUE></ITEM_EXTRAVALUE> <DEPT_CODE></DEPT_CODE> <DEPT_NAME></DEPT_NAME> <REPORTER></REPORTER> <REPORTER_NAME></REPORTER_NAME> <DATE_TIME></DATE_TIME> <ITEM_UP></ITEM_UP> <ITEM_DOWN></ITEM_DOWN> <ITEM_UNIT>mmol/L</ITEM_UNIT> <ITEM_STATUS>M</ITEM_STATUS> <CRITICALMINBAND></CRITICALMINBAND> <CRITICALMAXBAND></CRITICALMAXBAND> <CRITICALFLAG>0</CRITICALFLAG> <CRITICALREPLYFLAG></CRITICALREPLYFLAG> <ITEM_EXAMMETHOD></ITEM_EXAMMETHOD> <RELATED_ITEM_CODE></RELATED_ITEM_CODE> <BANDRANGE>-3--3</BANDRANGE> </ReportDetail> <ReportDetail> <REPORT_NO>LIS5404720</REPORT_NO> <VISIT_ID></VISIT_ID> <REPORT_TYPE>LIS</REPORT_TYPE> <REPORT_TYPE_NAME></REPORT_TYPE_NAME> <ITEM_CODE>BE(ecf)</ITEM_CODE> <ITEM_NAME>红细胞外液剩余碱</ITEM_NAME> <RELEVANT_LAB_TEST>1.3</RELEVANT_LAB_TEST> <ITEM_EXTRAVALUE></ITEM_EXTRAVALUE> <DEPT_CODE></DEPT_CODE> <DEPT_NAME></DEPT_NAME> <REPORTER></REPORTER> <REPORTER_NAME></REPORTER_NAME> <DATE_TIME></DATE_TIME> <ITEM_UP></ITEM_UP> <ITEM_DOWN></ITEM_DOWN> <ITEM_UNIT>mmol/L</ITEM_UNIT> <ITEM_STATUS>M</ITEM_STATUS> <CRITICALMINBAND></CRITICALMINBAND> <CRITICALMAXBAND></CRITICALMAXBAND> <CRITICALFLAG>0</CRITICALFLAG> <CRITICALREPLYFLAG></CRITICALREPLYFLAG> <ITEM_EXAMMETHOD></ITEM_EXAMMETHOD> <RELATED_ITEM_CODE></RELATED_ITEM_CODE> <BANDRANGE>-3--3</BANDRANGE> </ReportDetail> </Report></REPORTCOMMENT></CreateLisReport></soap:Body></soap:Envelope>";
endPoint6="http://"+testIp+":8886/InspectService.asmx";
soapAction6="http://tempuri.org/CreateLisReport";
break;
case 3:
soapAction6="http://tempuri.org/SynchReceiveBarcode";
soapXML6="<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Body><SynchReceiveBarcode xmlns=\"http://tempuri.org/\"><BARCODE>S018062508584</BARCODE><PERFORMED_BY>33600262</PERFORMED_BY><TECHNICIAN>012709</TECHNICIAN><STATUS>1</STATUS><SYSTEM_INDICATE>1</SYSTEM_INDICATE></SynchReceiveBarcode></soap:Body></soap:Envelope>";
endPoint6="http://"+testIp+":8886/InspectService.asmx";
break;
default:
break;
}
HttpURLConnection connection6 = SoapUtil.invokeSrvSoap(endPoint6,soapAction6, soapXML6);
threadData.put(Thread.currentThread(), connection6);
break;
default:
break;
}
}
int responseCode = threadData.get(Thread.currentThread()).getResponseCode();
synchronized (this) {
if(responseCode==200){
log.info(Thread.currentThread().getName()+"获得返回值");
String result = "";
InputStream is = threadData.get(Thread.currentThread()).getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
StringBuilder sb = new StringBuilder();
String temp = null;
while(null != (temp = br.readLine())){
sb.append(temp);
}
result = sb.toString();
log.info(Thread.currentThread().getName()+":"+result);
is.close();
isr.close();
br.close();
}
}
} catch (Exception e) {
number.incrementAndGet();
e.printStackTrace();
}finally {
cdAnswer.countDown(); //任务执行完毕,返回给指挥官,cdAnswer减1
log.info(Long.toString(cdAnswer.getCount()));
}
}
};
try {
for(int i=0;i<count;i++){
pool.execute(runnable);
}
Thread.sleep((long)(count*10));
synchronized (this) {
log.info("线程" + Thread.currentThread().getName() + "即将发布命令");
data = new Date();//这里就是所有线程并发时间点
log.info("线程" + Thread.currentThread().getName() + "已发送命令,正在等待结果");
cdOrder.countDown(); //发送命令,cdOrder减1,处于等待的战士们停止等待转去执行任务
}
cdAnswer.await(); //命令发送后指挥官处于等待状态,一旦cdAnswer为0时停止等待继续往下执行
log.info("线程" + Thread.currentThread().getName() + "已收到所有响应结果");
} catch (Exception e) {
e.printStackTrace();
}
long interval = new Date().getTime()-data.getTime();
String sql = "select sum(a.WSInterval)as sum,max(a.WSInterval) as max ,AVG(a.WSInterval) as avg from ("
+ "select top("+count+")* from wsm.dbo.CallLogs order by SerialNo desc)a";
Map<String,Object> map = esbsitMapper.commsql(sql);
String max = map.get("max").toString();
String sum = map.get("sum").toString();
String avg = map.get("avg").toString();
JSONObject result = new JSONObject();
result.put("failSum", number);
result.put("interval", interval);
result.put("sum", sum);
result.put("max", max);
result.put("avg", avg);
return ResultUtil.success(result);
}
以上是 java高并发 的全部内容, 来源链接: utcz.com/z/393964.html