A table have 300 records, The data refresh by one second . CPU
occupancy rate reaches to 20%,if I open several the IE pages then CPU
occupancy rate will reach to 90%,WHY????????????????
the code follows:
1、JaxcentSampleConfig.xml
<Page>
<PagePath>/testjaxcent/testMyselfTable.jsp</PagePath>
<PageClass>sample.TestMyselfTableSample</PageClass>
</Page>
2、web.xml
<servlet>
<servlet-name>JaxcentServlet</servlet-name>
<servlet-class>jaxcentServlet.JaxcentServlet</servlet-class>
<init-param>
<param-name>JaxcentConfigXML</param-name>
<param-value>/WEB-INF/JaxcentSampleConfig.xml</param-
value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>JaxcentServlet</servlet-name>
<url-pattern>/servlet/JaxcentServlet21/*</url-pattern>
</servlet-mapping>
3、jsp page
<%@ page language="java" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()
+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>real-time refresh</title>
<SCRIPT TYPE="text/javascript" SRC="<%=basePath%>/
jaxcenttest21.js"></SCRIPT>
</head>
<body>
<TABLE id="widgetsTable" BORDER=2 BGCOLOR="#D0D0D0">
<TR>
<TH>
 
</TH>
<TH>
Section 1
</TH>
<TH>
Section 2
</TH>
<TH>
Section 3
</TH>
<TH>
Section 4
</TH>
<TH>
Section 5
</TH>
<TH>
Section 6
</TH>
<TH>
Section 7
</TH>
<TH>
Section 8
</TH>
</TR>
<TR>
<TD>
Total
</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
.................................................................
.................................................................
.................................................................
.................................................................
<TR>
<TD>
Total
</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
</TABLE>
</body>
</html>
4、servlet code
package sample;
import java.text.DecimalFormat;
import jaxcent.*;
/**
* Jaxcent sample.
*
* Displays some simulated production counts in a table. The table
* is identified by an ID "widgetsTable".
*/
public class TestMyselfTableSample2 extends jaxcent.JaxcentPage {
static final int NSECTIONS = 8;
// The TABLE
HtmlTable table = new HtmlTable( this, "widgetsTable" );
// The timer thread for generating simulated data. In a real-life
situation,
// the data may be arriving from other sources asynchronously,
instead
// of from a timer!
Thread timerThread = null;
boolean running = false;
// Objects of interest on the page.
HtmlTableCell[][] tableCells = new HtmlTableCell[60][];
// We initialize the table cells in the constructor.
// Note: If there are any constructors specified for a JaxcentPage-
derived
// handler, there must be a public no-arg constructor.
public TestMyselfTableSample2()
{
try {
// Initialize the table cells array.
for ( int i = 0; i < 60; i++ ) {
tableCells[i] = new HtmlTableCell[NSECTIONS];
HtmlTableRow row = table.getRow( 1+i );
// The "1+i" is because of the header row.
for ( int j = 0; j < NSECTIONS; j++ ){
tableCells[i][j] = row.getCell( 1+j );
//
System.out.println( "sddddddddddddddddddddddddd"+row.getCell( 1+j ).getAlign());
}
}
// Start a timer for updates.
running = true;
timerThread = new Thread() {
public void run() {
simulateData();
}
};
timerThread.start();
} catch (Exception ex) {
ex.printStackTrace();
}
}
// Stop the thread on page unloading.
protected void onUnload()
{
running = false;
timerThread.interrupt();
}
// Data simulation
void simulateData()
{
while ( true ) {
DecimalFormat df = new DecimalFormat("0.0000");
// Fill the table.
try {
for ( int i = 0; i < NSECTIONS; i++ ) {
for ( int j = 0; j < 60; j++ ) {
tableCells[j]
[i].setInnerText(df.format(Math.random()));
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
try {
Thread.sleep( 1000 );
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
--
You received this message because you are subscribed to the Google Groups "Jaxcent" group.
To post to this group, send email to
jaxcen...@googlegroups.com.
To unsubscribe from this group, send email to
jaxcentgroup...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/jaxcentgroup?hl=en.