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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
MaClasse cl = new MaClasse("param1", "param2");
cl.init();
//creation des threads de chaque methode
//T1: Thread de la methode tache1
Runnable t1 = new leThread(cl, 1);
Thread T1 = new Thread(t1);
//T2: Thread de la methode tache2
Runnable t2 = new leThread(cl, 2);
Thread T2 = new Thread(t2);
//T3: Thread de la methode tache3
Runnable t3 = new leThread(cl, 3);
Thread T3 = new Thread(t3);
//T4: Thread de la methode tache4
Runnable t4 = new leThread(cl, 4);
Thread T4 = new Thread(t4);
//T5: Thread de la methode tache5
Runnable t5 = new leThread(cl, 5);
Thread T5 = new Thread(t5);
//T6: Thread de la methode tache6
Runnable t6 = new leThread(cl, 6);
Thread T6 = new Thread(t6);
//T7: Thread de la methode tache7
Runnable t7 = new leThread(cl, 7);
Thread T7 = new Thread(t7);
//T8: Thread de la methode tache8
Runnable t8 = new leThread(cl, 8);
Thread T8 = new Thread(t8);
out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
out.println("<HTML>");
out.println("<HEAD>");
out.println("<TITLE>ma servlet</TITLE></HEAD>");
out.println(" <BODY>");
out.println("Début tache1 ...<br>");
T1.start();
out.flush();
out.println("Début tache2 ...<br>");
T2.start();
out.flush();
out.println("Début tache3 ...<br>");
T3.start();
out.flush();
while (T1.isAlive()) {;}
out.println("Fin tache1 ...");
out.println("Début tache4 ...<br>");
T4.start();
out.flush();
while(T4.isAlive()) {;}
out.println("Fin tache4 ...<br>");
out.println("Début tache5 ...<br>");
T5.start();
out.flush();
while(T2.isAlive() || T4.isAlive()) {;}
out.println("Fin tache4 ...<br>");
out.println("Début tache6 ...<br>");
T6.start();
out.flush();
while(T5.isAlive()) {;}
out.println("Fin tache5 ...<br>");
out.println("Début tache7 ...<br>");
T7.start();
out.flush();
while(T1.isAlive() || T2.isAlive() || T3.isAlive() || T4.isAlive() || T5.isAlive() || T6.isAlive() || T7.isAlive()) {;}
out.println("Fin tache6 et tache7 ...<br>");
out.println("Début tache8 ...<br>");
T8.start();
out.flush();
while(T8.isAlive()) {;}
out.println("Fin de toutes les taches ...<br>");
out.println(" </BODY>");
out.println("</HTML>");
out.flush();
out.close();
} |
Partager