🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: How to allow messages during long processes ?

#16188
From: Jeff Rafter
Date: Wed, 24 Mar 1999 00:00
42 lines
1591 bytes
George,

Here is how to do a thread quickly (If you already knew this *sorry*
consider it valuable to others who don't know) :

public class myApplet extends Applet implements Runnable {

  Thread hugeProcess;

  // start and stop happen often.  Instead you could override init and
destory
  // if you use init() and destory() your thread will continue to run when
your applet
  // is minimized
  public void start() {
    if (hugeProcess != null) {
      hugeProcess = new Thread(this);
      hugeProcess.start();
    }
  }

  public void stop() {
    hugeProcess = null;
  }

  public void run() {
    Thread current = new Thread.currentThread();
    while (hugeProcess == current) {
        ...do some code
        try {
          Thread.sleep(100); // sleep can be called with any amount of time
        } catch (InterruptedException e) { }
  }



}

Good Luck
Jeff Rafter
Realsoft Development
www.realsoftdev.com
Technical Details
Message-ID: <7db2ke$nsc12@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <7da2m2$mrl8@forums.borland.com> <36F8F25A.4F8AACBE@sciatl.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,57b0134e8285e481
X-Google-Attributes: gidf74b3,public
From: "Jeff Rafter" <jeffrafter@earthlink.net>
Subject: Re: How to allow messages during long processes ?
Date: 1999/03/24
Message-ID: <7db2ke$nsc12@forums.borland.com>
X-Deja-AN: 458420885
References: <7da2m2$mrl8@forums.borland.com> <36F8F25A.4F8AACBE@sciatl.com>
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.0810.800
Organization: Realsoft Development
X-MSMail-Priority: Normal
Reply-To: "Jeff Rafter" <jeffrafter@earthlink.net>
Newsgroups: borland.public.jbuilder.java.language