KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > rift > coad > lib > thread > CoadunationThread


1 /*
2  * CoadunationLib: The coaduntion implementation library.
3  * Copyright (C) 2006 Rift IT Contracting
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  * CoadunationThread.java
20  *
21  * The coadunation thread class.
22  */

23
24 // package path
25
package com.rift.coad.lib.thread;
26
27 import com.rift.coad.lib.security.UserSession;
28
29
30 /**
31  * The coadunation thread class.
32  *
33  * @author Brett Chaldecott
34  */

35 public class CoadunationThread extends BasicThread {
36     
37     /**
38      *
39      * Creates a new instance of CoadunationThread
40      */

41     public CoadunationThread() throws Exception JavaDoc {
42     }
43     
44     
45     /**
46      *
47      * Creates a new instance of CoadunationThread setting the runnable reference.
48      *
49      *
50      * @param runnable The reference to the runnable object.
51      */

52     public CoadunationThread(BasicRunnable runnable) throws Exception JavaDoc {
53         super(runnable);
54     }
55     
56     
57     /**
58      * This method cannot be used on a coadunation thread.
59      */

60     public void start() throws IllegalThreadStateException JavaDoc {
61         throw new IllegalThreadStateException JavaDoc("Cannot user this method use" +
62                 " start(Username) instead");
63     }
64     
65     
66     /**
67      * This method overrides the start method to bind this thread to the
68      * thread group.
69      *
70      * @exception IllegalThreadStateException
71      */

72     public void start(String JavaDoc username) throws IllegalThreadStateException JavaDoc {
73         try {
74             ThreadGroupManager.getInstance().addThreadToGroup(this,username);
75             super.start();
76         } catch (Exception JavaDoc ex) {
77             throw new IllegalThreadStateException JavaDoc(
78                     "Failed to start the thread : " + ex.getMessage());
79         }
80     }
81 }
82
Popular Tags