KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > controller > loadbalancer > tasks > KillThreadTask


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Copyright (C) 2002-2004 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Contact: c-jdbc@objectweb.org
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation; either version 2.1 of the License, or any later
10  * version.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20  *
21  * Initial developer(s): Emmanuel Cecchet.
22  * Contributor(s): Julie Marguerite.
23  */

24
25 package org.objectweb.cjdbc.controller.loadbalancer.tasks;
26
27 import java.sql.SQLException JavaDoc;
28
29 import org.objectweb.cjdbc.controller.loadbalancer.BackendWorkerThread;
30
31 /**
32  * This task is used to kill backend worker threads.
33  *
34  * @author <a HREF="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet</a>
35  * @author <a HREF="mailto:Julie.Marguerite@inria.fr">Julie Marguerite</a>
36  * @version 1.0
37  */

38 public class KillThreadTask extends AbstractTask
39 {
40
41   /**
42    * Creates a new <code>KillThreadTask</code> instance that must be executed
43    * by <code>nbToComplete</code> backend threads
44    *
45    * @param nbToComplete number of threads that must succeed before returning
46    * @param totalNb total number of threads
47    */

48   public KillThreadTask(int nbToComplete, int totalNb)
49   {
50     super(nbToComplete, totalNb);
51   }
52
53   /**
54    * This function call the backendThread kill function and notifies the task
55    * completion success.
56    *
57    * @param backendThread the backend thread that will execute the task
58    * @throws SQLException if an error occurs
59    */

60   public void executeTask(BackendWorkerThread backendThread)
61       throws SQLException JavaDoc
62   {
63     backendThread.killWithoutDisablingBackend();
64     notifySuccess();
65   }
66
67   /**
68    * @see java.lang.Object#toString()
69    */

70   public String JavaDoc toString()
71   {
72     return "KillThreadTask";
73   }
74 }
Popular Tags