🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #15886

Re: multi-threading

#15886
From: Michael A. Long
Date: Tue, 27 Apr 1999 00:00
50 lines
2380 bytes
Just looking at the code, it looks as though you are starting only one
thread and when the object you create inside its run() method ends, so does
the Thread.  Personally I like to keep track of things a little better and
either extend from the Thread class or implement the Runnable interface.
Keeps things a little easier to follow.
something like:

public class FormDisplayTable extends Thread{
    public void run(){
        while(thread_keep_alive_condition){
            do stuff here;
        }// while
    }// run
} // Class:FormDisplayTable

then you could instanciate one instance of the thread from another instance
and as long as there is some kind of looping structure to keep the first
thread alive, it would not exit.

This also keeps more closely with Java's object oriented approach.

John McNair wrote in message <3724F478.93B5B7E0@compsolve.com>...
>    I am having a problem with multi-threading with a very simple
>example.  The user makes some choices on a form, and based on those
>choices, another form is spawned which merely displays a table object
>with data generated from the user choices.  When I close the table form,
>the parent form is killed as well.  Here is the code that launches the
>second form:
>
>      // Make a new thread here.
>      Thread thrfrmDisplayTable1 = new Thread() {
>        public void run() {
>          frmDisplayTable frmDisplayTable1 = new frmDisplayTable();
>          frmDisplayTable1.strTmpData = "SELECT * FROM " +
>strTmpTableName;
>          frmDisplayTable1.OpenData();
>          frmDisplayTable1.setVisible(true);
>          frmDisplayTable1.strTmpTableName = strTmpTableName;
>        }
>      };
>      thrfrmDisplayTable1.start();
>
>Why wouldn't killing the second form leave the first untouched?
>
>--
>John McNair
>Computing Solutions
>jmcnair@compsolve.com
>
>
Technical Details
Message-ID: <7g4708$icd13@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <3724F478.93B5B7E0@compsolve.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,aa6859e95fc687e5
X-Google-Attributes: gidf74b3,public
From: "Michael A. Long" <mlong@ecst.csuchico.edu>
Subject: Re: multi-threading
Date: 1999/04/27
Message-ID: <7g4708$icd13@forums.borland.com>
X-Deja-AN: 471427450
References: <3724F478.93B5B7E0@compsolve.com>
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
Organization: California State University, Chico
Newsgroups: borland.public.jbuilder.java.language