/[projects]/miscJava/Test3/src/dk/thoerup/asyncsamples/SimpleThreading.java
ViewVC logotype

Contents of /miscJava/Test3/src/dk/thoerup/asyncsamples/SimpleThreading.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 645 - (show annotations) (download)
Mon Apr 12 12:53:28 2010 UTC (14 years, 1 month ago) by torben
File size: 1130 byte(s)
Added some samples for async code execution 
1 /* this example old-school Thread / Runnable's - which should under no circumstances be used from a java EE environment.
2 *
3 * This is only for documentation purposes .... if you need to run async code, you should investigate some of the other examples
4 *
5 * There's no guarantee that this will ever work on your chosen java container.
6 */
7
8 package dk.thoerup.asyncsamples;
9
10 import java.io.IOException;
11 import java.util.logging.Logger;
12
13 import javax.servlet.ServletException;
14 import javax.servlet.http.HttpServlet;
15 import javax.servlet.http.HttpServletRequest;
16 import javax.servlet.http.HttpServletResponse;
17
18 public class SimpleThreading extends HttpServlet {
19
20 static final Logger logger = Logger.getLogger( SimpleThreading.class.getName() );
21
22 class Worker implements Runnable {
23 @Override
24 public void run() {
25 DummyWork.doWork();
26 }
27 }
28
29 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
30 response.getWriter().write("Starting async thread");
31
32 Thread t = new Thread( new Worker() );
33 t.start();
34 }
35
36 }

  ViewVC Help
Powered by ViewVC 1.1.20