if you want to see all message you should add below lines
after "t.say()".
--------------------------
try{
       t.join();
}catch(Exception e) {}
--------------------------

                        T t = new T(res.getWriter());
                        t.start();   <--
                        t.say(); <-- this line is worked by main servlet thread.


The reason you see only t.say() message is servlet main thread is destroyed before T 
thread execute lines in his run method...
So main servlet thread should wait for ending of T thread.
It is "t.join()"....
okay?

----- Original Message -----
From: "Balamurugan.K, AMB Chennai" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, August 02, 2000 6:57 PM
Subject: Problem with the thread in the servlet


>
> Hi,
>    see this code:
>
>         import java.io.*;
>         import java.util.*;
>         import javax.servlet.*;
>         import javax.servlet.http.*;
>
>
>         public class ThreadTest extends HttpServlet {
>                 public void doGet(HttpServletRequest req,HttpServletResponse
> res) throws IOException {
>                         T t = new T(res.getWriter());
>                         t.start();  // this is not printing any values.why?
>                         t.say(); // this works well...
>                 }
>         }
>         class T extends Thread {
>                 PrintWriter out;
>                 public T(PrintWriter pwt) throws IOException{
>                         this.out = pwt;
>                 }
>                 public say() {
>                         out.println("Working Well----from say()");
>                 }
>                 public void run() {
>                         out.println("Working Well----from Thread");
>                 }
>         }
>
>         This program prints only for say() method, whereas it is not
> printing anything when i call this thru thread.
>         can any one tell why .......?
>
>
> Regards,
> Balamurugan K,
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to