[5042] in java-interest

home help back first fref pref prev next nref lref last post

Re: problems hooking up a TextArea to a DataInputStream

daemon@ATHENA.MIT.EDU (Walter Szewelanczyk)
Fri Jan 26 18:34:17 1996

From: "Walter Szewelanczyk" <Walter@stumpy.adco.com>
To: James Waldrop <sulam@construct.net>, java-interest@java.Eng.Sun.COM
Date: Fri, 26 Jan 1996 17:19:01 +0000

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.

********************************************************************************************
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

home help back first fref pref prev next nref lref last post