From: vaibhav on
Hi all,
I have a java program with 3 thread, thread1 , thread2 ,
thread3. When I call thread1.run() , thread2.run() and
thread3.run() .. the execution of thread1 and thread2 start but
thread3 does not run.
Thread1 contains linked list handling , Thread2 contains
execution of "tcpdump" command and Thread3 contains execution of
"ping" command. Can anybody tell me why my thread3 is not running ??
From: rossum on
On Sat, 13 Mar 2010 00:58:01 -0800 (PST), vaibhav
<khatavkarvaibhav86(a)gmail.com> wrote:

>Hi all,
> I have a java program with 3 thread, thread1 , thread2 ,
>thread3. When I call thread1.run() , thread2.run() and
>thread3.run() .. the execution of thread1 and thread2 start but
>thread3 does not run.
> Thread1 contains linked list handling , Thread2 contains
>execution of "tcpdump" command and Thread3 contains execution of
>"ping" command. Can anybody tell me why my thread3 is not running ??
Is the problem the order of the threads? What happens if you fire
them off in a different order? 321, 132, 213 etc.

Is the problem with the ping command? Change thread3 to display
"Hello World" on the console instead of pinging. Does that help?

Try to run ping alone from an unthreaded program. Does it work?

Is the problem with the number of threads. Cut out thread1 and
thread2, just run thread3. Does that work? What about with just two
threads? Four threads?

rossum

From: John B. Matthews on
In article <cj0np558v4pep9jkaqrlsu8qpp0siv2qcn(a)4ax.com>,
rossum <rossum48(a)coldmail.com> wrote:

> On Sat, 13 Mar 2010 00:58:01 -0800 (PST), vaibhav
> <khatavkarvaibhav86(a)gmail.com> wrote:
>
> >Hi all,
> >I have a java program with 3 thread, thread1 , thread2 , thread3.
> >When I call thread1.run() , thread2.run() and thread3.run() .. the
> >execution of thread1 and thread2 start but thread3 does not run.
> >Thread1 contains linked list handling , Thread2 contains execution
> >of "tcpdump" command and Thread3 contains execution of "ping"
> >command. Can anybody tell me why my thread3 is not running ??
> Is the problem the order of the threads? What happens if you fire
> them off in a different order? 321, 132, 213 etc.
>
> Is the problem with the ping command? Change thread3 to display
> "Hello World" on the console instead of pinging. Does that help?
>
> Try to run ping alone from an unthreaded program. Does it work?
>
> Is the problem with the number of threads. Cut out thread1 and
> thread2, just run thread3. Does that work? What about with just two
> threads? Four threads?

vaibhav: In addition to the systematic approach suggested by rossum,
verify that thread3 isn't terminating abruptly by providing an
UncaughtExceptionHandler:

<http://java.sun.com/javase/6/docs/api/java/lang/Thread.html>

More discussion may be found here:

<http://www.ibm.com/developerworks/java/library/j-jtp0924.html>

--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
From: Patricia Shanahan on
vaibhav wrote:
> Hi all,
> I have a java program with 3 thread, thread1 , thread2 ,
> thread3. When I call thread1.run() , thread2.run() and
> thread3.run() .. the execution of thread1 and thread2 start but
> thread3 does not run.

Do you literally mean you are calling e.g. thread2.run(), or are you
calling thread2.start(), which creates a new thread and invokes the
Thread object's run() method in it?

Patricia
From: Lew on
vaibhav wrote:
>> I have a java [sic] program with 3 thread, thread1 , thread2 ,
>> thread3. When I call thread1.run() , thread2.run() and
>> thread3.run() .. the execution of thread1 and thread2 start but
>> thread3 does not run.

<http://sscce.org/>

Patricia Shanahan wrote:
> Do you literally mean you are calling e.g. thread2.run(), or are you
> calling thread2.start(), which creates a new thread and invokes the
> Thread object's run() method in it?

That's exactly the sort of question an SSCCE can answer, and this sort of
vague, "I have a problem, what's the solution?" type of post cannot.

<http://sscce.org/>
<http://sscce.org/>
<http://sscce.org/>

--
Lew