[5045] in java-interest
Re: problems hooking up a TextArea to a DataInputStream
daemon@ATHENA.MIT.EDU (Walter Szewelanczyk)
Fri Jan 26 19:51:45 1996
From: "Walter Szewelanczyk" <Walter@stumpy.adco.com>
To: sulam@construct.net
Date: Fri, 26 Jan 1996 18:25:40 +0000
CC: java-interest@java.sun.com
Hi again James,
>
>Hi James,
>
>
> [text deleted]
>
> I've gotten a socket hooked up to a DataInputStream, and am even able
> to call readLine() on it and get back something. The problem is that
> this isn't working past the first line. I suspect the problem is
> something in the way I'm handling the threads, since I'm not clear
> on how it should be done. Anyway, the relevant bits of code are:
>
> [text deleted]
>
> public void run() {
> String line;
>
> try { line = in.readLine(); }
> catch (Exception e) { line = null; }
>
> if (line != null) { outputArea.appendText(line); }
> }
>
> [text deleted]
>
>Threads provide functionality by implimenting thier run method. When the
>run method exits the thread terminates. Your applet implements the
>run interface so when after your (blocking) readLine() you exit. So
>this is why you only get one line of text. You will want a loop to
>get more lines.
>
>
>Hope this helps,
>
>Walt
>
>P.S. you had a variable engine which was a instance of a plain vanilla
>Thread. I don't think you need it.
I mis read the engine variable. You DO NEED IT sorry. Not sure what
I was thinking (oops) :-)
walt
********************************************************************************************
Walter Szewelanczyk Technical Director
Walter@adco.com NET VENTURE, Inc.
"One must stay in a very RIGID state of FLEXABILITY"
********************************************************************************************
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com