001: // @@
002: // @@
003: /*
004: * Wi.Ser Framework
005: *
006: * Version: 1.8.1, 20-September-2007
007: * Copyright (C) 2005 Dirk von der Weiden <dvdw@imail.de>
008: *
009: * This library is free software; you can redistribute it and/or
010: * modify it under the terms of the GNU Lesser General Public
011: * License as published by the Free Software Foundation; either
012: * version 2 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017: * Lesser General Public License for more details.
018: *
019: * You should have received a copy of the GNU Lesser General Public
020: * License along with this library located in LGPL.txt in the
021: * license directory; if not, write to the
022: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
023: * Boston, MA 02111-1307, USA.
024: *
025: * If this agreement does not cover your requirements, please contact us
026: * via email to get detailed information about the commercial license
027: * or our service offerings!
028: *
029: */
030: // @@
031: package de.ug2t.kernel;
032:
033: import java.util.*;
034:
035: public class KeNameSpaceThread extends Thread {
036: private HashMap pem_subThreads = null;
037: private Thread pem_parent = null;
038:
039: /**
040: *
041: */
042:
043: protected void pcmf_construct() {
044: Thread l_thread = Thread.currentThread();
045: this .pem_parent = l_thread;
046: if (l_thread instanceof KeNameSpaceThread)
047: ((KeNameSpaceThread) l_thread).pcmf_addSubThread(this );
048: };
049:
050: public KeNameSpaceThread() {
051: super ();
052: this .pcmf_construct();
053: }
054:
055: public KeNameSpaceThread(Runnable arg0) {
056: super (arg0);
057: this .pcmf_construct();
058: }
059:
060: public KeNameSpaceThread(String arg0) {
061: super (arg0);
062: this .pcmf_construct();
063: }
064:
065: public KeNameSpaceThread(ThreadGroup arg0, Runnable arg1) {
066: super (arg0, arg1);
067: this .pcmf_construct();
068: }
069:
070: public KeNameSpaceThread(Runnable arg0, String arg1) {
071: super (arg0, arg1);
072: this .pcmf_construct();
073: }
074:
075: public KeNameSpaceThread(ThreadGroup arg0, String arg1) {
076: super (arg0, arg1);
077: this .pcmf_construct();
078: }
079:
080: public KeNameSpaceThread(ThreadGroup arg0, Runnable arg1,
081: String arg2) {
082: super (arg0, arg1, arg2);
083: this .pcmf_construct();
084: }
085:
086: public KeNameSpaceThread(ThreadGroup arg0, Runnable arg1,
087: String arg2, long arg3) {
088: super (arg0, arg1, arg2, arg3);
089: this .pcmf_construct();
090: }
091:
092: public synchronized void pcmf_addSubThread(Thread xSub) {
093: if (this .pem_subThreads == null)
094: this .pem_subThreads = new HashMap();
095:
096: this .pem_subThreads.put(xSub.getName(), xSub);
097: };
098:
099: public synchronized void pcmf_removeSubThread(Thread xSub) {
100: if (this .pem_subThreads == null)
101: return;
102:
103: this .pem_subThreads.remove(xSub.getName());
104: };
105:
106: public synchronized ArrayList pcmf_getSubThreadVect() {
107: if (this .pem_subThreads == null)
108: return (null);
109: else
110: return (new ArrayList(pem_subThreads.values()));
111: }
112:
113: public synchronized int pcmf_getSubThreadCount() {
114: if (this .pem_subThreads == null)
115: return (0);
116:
117: return (pem_subThreads.size());
118: }
119:
120: public synchronized Iterator pcmf_getSubThreadIt() {
121: if (this .pem_subThreads == null)
122: return (new ArrayList().iterator());
123: else
124: return (new ArrayList(pem_subThreads.values()).iterator());
125: }
126:
127: public Thread pcmf_getParent() {
128: return (this .pem_parent);
129: };
130:
131: public void setNSThreadName(String Name) {
132: if (this .pem_parent instanceof KeNameSpaceThread) {
133: ((KeNameSpaceThread) this .pem_parent)
134: .pcmf_removeSubThread(this );
135: super .setName(Name);
136: ((KeNameSpaceThread) this.pem_parent)
137: .pcmf_addSubThread(this);
138: return;
139: }
140: super.setName(Name);
141: return;
142: }
143: }
|