The server is Domino602CF1, and when i use background thread at servlet, it can init and no error info.but it not work!But the servlet work fine at tomcat !Does domino not support backgroud thread!!
Sample Code:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class VoteCheck extends HttpServlet implements Runnable
{
long candidateA = 0;
long candidateB = 0;
long candidateC = 0;
boolean stopFlag = false;
Thread voteCount;
public void init() throws ServletException
{
voteCount = new Thread(this); //instantiate a new thread
voteCount.setPriority(Thread.MIN_PRIORITY); //set priority
voteCount.start(); //start the new thread running
}
public void run()
{
System.out.println("Start....") //<---not work!!!!!!!!!!!!!
while (true)
{
//add a random number between 0 and 10 to each candidate
candidateA += Math.random() * 10;
candidateB += Math.random() * 10;
candidateC += Math.random() * 10;
if (stopFlag) //exit run() method if stopFlag is true
{
return;
}
try
{
Thread.sleep(1000); //pause for 1 second
}
catch (InterruptedException e)
{
}
}
}
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
//generate the HTML showing the election results
out.println("<HTML>");
out.println("<HEAD><TITLE>Election Results</TITLE></HEAD>");
out.println("<BODY>");
out.println("<B>ELECTION RESULTS</B><BR>");
out.println(new Date() + "<BR><BR>");
out.println("Candidate A: " + candidateA + "<BR>");
showBar(out, candidateA, "red");
out.println("Candidate B: " + candidateB + "<BR>");
showBar(out, candidateB, "blue");
out.println("Candidate C: " + candidateC + "<BR>");
showBar(out, candidateC, "green");
out.println("</BODY></HTML>");
out.close(); //close the output stream
}
private void showBar(PrintWriter out, long votes,
String color)
{
out.println("<TABLE BORDER=\"0\" BGCOLOR=\"" + color +
"\" WIDTH=\"" + votes + "\">");
out.println("<TR><TD> </TD></TR>");
out.println("</TABLE><BR>");
}
public void destroy()
{
stopFlag = true;
}
}