🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Threads

#17414
From: Vladimir Olenin
Date: Thu, 19 Nov 1998 00:00
101 lines
3683 bytes
This is a multi-part message in MIME format.
--------------204783E7D9BDDC6E6B70CFB8
Content-Type: text/plain; charset=koi8-r
Content-Transfer-Encoding: 7bit

Hi, mariano,

Thanks for your advice, but do u think it's really good idea? The first
thing that stops me is resource leaking problem. Do u think RAM would be
completely freed in this case (without calling stop function)? And
another one, how do u suppose to change mustExit variable? U can ran
into a situation when mustExit is compared to the "true" value in run()
method and at the same time u change it (mustExit) to false from another
function. Anyway it would be great to have a look at your program (if
it's really simple and short :)) ), since i could get there some ideas
about solution of this problem.

mariano podesta wrote:
> 
> using Thread.stop() is a bad thing!
> try to use a boolean field (like private boolean mustExit) to verify in
> your run()s main loop like
> 
>   public void run()
>   {
>    while (!mustExit)
>    {
>         <your code here> // thread is processing
>     }
>     <more code> // thread is out!
>   }
> 
> i made a simple tetris and i use 2 threads and i think that this way
> (boolean field) is the best.
> send me an e-mail if you want to see it (tetris with code if you like).
> bye.
> 
> Vladimir Olenin wrote:
> 
> > Hi,
> >
> > I hava the following:
> >
> > public class Connection extens Thread{
> >
> >   public Connection(){
> >     .....
> >
> >     this.start();
> >   }
> >
> >   public void run(){
> >     .....
> >   }
> >
> >   public void closeConnection(){
> >     .....
> >
> >     if(this.isAlive()) // THE PROGRAM
> >       this.stop();     // HANGS HERE !!!
> >   }
> > }
> >
> > When i try to stop the thread, the program just hangs. I suppose it's a
> > problem of synchronization. Any help at all would be very appreciated.
> > It'd be great to have an example or link to some tutorial concerning
> > threads.
> >
> >                        Vladimir
> >
> > --
> > >~~~~~~~~<=============>~~~~~~~~<
> > Be yourself no matter what they say...
> > Join in Java community now!
> > http://www.geocities.com/SiliconValley/Heights/9815
> > >~~~~~~~~<=============>~~~~~~~~<

-- 
>~~~~~~~~<=============>~~~~~~~~<
Be yourself no matter what they say...
Join in Java community now!
http://www.geocities.com/SiliconValley/Heights/9815
>~~~~~~~~<=============>~~~~~~~~<
--------------204783E7D9BDDC6E6B70CFB8
Content-Type: text/x-vcard; charset=koi8-r;
 name="keenonjava.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Vladimir Olenin
Content-Disposition: attachment;
 filename="keenonjava.vcf"

begin:vcard 
n:Vladimir;Olenin
x-mozilla-html:FALSE
adr:version:2.1;;;;;;
version:2.1
email;internet:keenonjava@collegemail.com
note:Java programmer. Open for project development offers. See my home page at: http://www.geocities.com/SiliconValley/Heights/9815/
end:vcard

--------------204783E7D9BDDC6E6B70CFB8--
Technical Details
Message-ID: <36534612.908F7244@collegemail.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <365078D0.6AC9F125@collegemail.com> <3651927C.AD1C9CED@netscape.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,193974b4bf6e2907
X-Google-Attributes: gidf74b3,public
From: Vladimir Olenin <keenonjava@collegemail.com>
Subject: Re: Threads
Date: 1998/11/19
Message-ID: <36534612.908F7244@collegemail.com>
X-Deja-AN: 413291784
References: <365078D0.6AC9F125@collegemail.com> <3651927C.AD1C9CED@netscape.net>
To: mariano podesta <marianop@netscape.net>
X-Accept-Language: en,ru
Content-Type: multipart/mixed; boundary="------------204783E7D9BDDC6E6B70CFB8"
Organization: Another Netscape Collabra Server User
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language