> The context is: I have one class (not thread class), and in this class
> I have two class extended by thread. In one of the thread class, I have
[quoted text clipped - 4 lines]
>
> Are you understand me?
It's definately a challenge for me. You say that you have a class extended
by Thread, which means (to me, at least) that you have somehow made the
system java.lang.Thread class extend (subclass) your class. This is
extremely unlikely. I am more likely to believe there is a language problem
and that you really have a class that contains two objects whose classes
extend (are subclasses of) Thread. One thread opens a file and writes.
Overally, I'm still really not sure what you're asking. My questions to you
(to help you better) are:
Do you mean extends and not extended by?
Do you really need to extend Thread at all instead of supplying a Runnable?
Why do you think you need to have a thread that starts other threads?
What do you really want these threads to do?
Cheers,
Matt Humphrey matth@ivizNOSPAM.com http://www.iviz.com/
yuriff@gmail.com - 15 May 2006 12:49 GMT
My File.java is:
class File{
public File(int poolSize){
//start poolSize threads of the PoolThreads
}
private final class PoolThreads extends Thread{
public void run(){
...
exec(some parameters);
...
}
private int exec(some parameters){
...
new ProcThread().start();
...
}
}
public class ProcThread extends Threads{
...
}
}
What was wrong with him?
Matt Humphrey - 16 May 2006 03:01 GMT
> My File.java is:
>
[quoted text clipped - 22 lines]
>
> What was wrong with him?
Well, this answers the first question in that you have classes that extend
Thread. It certainly is possible to have a thread that instantiates
another thread. This brings us to the question of whether doing so solves
the problem. I guess you are trying to make a thread pool, but it would
really help if you could say what you want this to do. A thread pool is not
a kind of thread itself, so it is probably not meaningful to have it extend
Thread. In addition, there are some well-known techniques for this--see
these links.
http://www.informit.com/articles/article.asp?p=30483&rl=1
http://www-128.ibm.com/developerworks/library/j-jtp0730.html
Also the latest versions (1.5) of Java appear to include a ThreadPool
system. I havn't used these, but look for "ThreadPoolExecutor" and you will
probably save yourself a huge amount of trouble.
Cheers,
Matt Humphrey matth@ivizNOSPAM.com http://www.iviz.com/