1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | <%@ taglib prefix="b" uri="/WEB-INF/bigpipe.tld"%> <%long pstart = System.currentTimeMillis();%> <b:multiThread pageLetNum="6" bigPipeJSPath="js/bigpipeMulti.js"> <table border="1" width="100%" height="500"> <caption> 多线程例子 </caption> <tr> <td><b:pageLet dealClass="com.bigpipe.tag.Index1" name="index1"> 编号:1<img src="images/loading.gif"/> </b:pageLet></td> <td><b:pageLet dealClass="com.bigpipe.tag.Index2" name="index2"> 编号:2<img src="images/loading.gif"/> </b:pageLet></td> <td><b:pageLet dealClass="com.bigpipe.tag.Index3" name="index3"> 编号:3<img src="images/loading.gif"/> </b:pageLet></td> </tr> <tr> <td><b:pageLet dealClass="com.bigpipe.tag.Index4" name="index4"> 编号:4<img src="images/loading.gif"/> </b:pageLet></td> <td><b:pageLet dealClass="com.bigpipe.tag.Index5" name="index5"> 编号:5<img src="images/loading.gif"/> </b:pageLet></td> <td><b:pageLet dealClass="com.bigpipe.tag.Index6" name="index6"> 编号:6<img src="images/loading.gif"/> </b:pageLet></td> </tr> </table> </b:multiThread> <%long secs = System.currentTimeMillis() - pstart;%> 整个页面加载耗费了:<%=secs%> 毫秒 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | @Override public boolean start(Writer writer) { boolean start = super.start(writer); try { writer.write("<script type='text/javascript' src='" + bigPipeJSPath + "'></script>"); } catch (IOException e) { e.printStackTrace(); } return start; } @Override public boolean end(Writer writer, String body) { boolean end = super.end(writer, body); CountDownLatch c = (CountDownLatch)request.getAttribute(MultiThreadTag.COUNT_DOWN); try { //等待所有的PageLet结束 c.await(); } catch (InterruptedException e) { e.printStackTrace(); } return end; } |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |