Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #18686

Re: can't throw

Newsgroups comp.lang.java.programmer
Date 2012-09-12 11:40 -0700
References <19af6b94-7a1e-4491-afb2-79782406f560@googlegroups.com> <abaoivFqnh9U1@mid.individual.net>
Message-ID <e726309e-8aa2-45e7-8452-80f1c2ef1b3f@googlegroups.com> (permalink)
Subject Re: can't throw
From bob smith <bob@coolfone.comze.com>

Show all headers | View raw


On Wednesday, September 12, 2012 1:32:01 AM UTC-5, Robert Klemme wrote:
> On 11.09.2012 22:16, bob smith wrote:
> 
> > Am I the only one who wanted to throw an Exception but couldn't
> 
> > because I was overriding a method that threw nothing?
> 
> >
> 
> > In particular, I'm subclassing Thread and can't throw an Exception in
> 
> > the run method.  I suspect this is a more general issue though.
> 
> 
> 
> Why are you subclassing Thread in the first place?
> 
> 
> 
> Kind regards
> 
> 
> 
> 	robert
> 
> 
> 
> -- 
> 
> remember.guy do |as, often| as.you_can - without end
> 
> http://blog.rubybestpractices.com/

There are two ways to create a new thread of execution. One is to declare a class to be a subclass of Thread. This subclass should override the run method of class Thread. An instance of the subclass can then be allocated and started. For example, a thread that computes primes larger than a stated value could be written as follows:

     class PrimeThread extends Thread {
         long minPrime;
         PrimeThread(long minPrime) {
             this.minPrime = minPrime;
         }
 
         public void run() {
             // compute primes larger than minPrime
              . . .
         }
     }
 
The following code would then create a thread and start it running:

     PrimeThread p = new PrimeThread(143);
     p.start();

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

can't throw bob smith <bob@coolfone.comze.com> - 2012-09-11 13:16 -0700
  Re: can't throw markspace <-@.> - 2012-09-11 13:34 -0700
    Re: can't throw Lew <lewbloch@gmail.com> - 2012-09-11 14:15 -0700
  Re: can't throw Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-09-11 17:02 -0400
    Re: can't throw Lew <lewbloch@gmail.com> - 2012-09-11 14:17 -0700
      Re: can't throw Arne Vajhøj <arne@vajhoej.dk> - 2012-09-11 21:21 -0400
        Re: can't throw Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2012-09-11 21:59 -0700
          Re: can't throw Gene Wirchenko <genew@ocis.net> - 2012-09-12 09:18 -0700
            Re: can't throw Robert Klemme <shortcutter@googlemail.com> - 2012-09-12 19:09 +0200
            Re: can't throw markspace <-@.> - 2012-09-12 10:56 -0700
            Re: can't throw Arne Vajhøj <arne@vajhoej.dk> - 2012-09-12 18:36 -0400
              Re: can't throw Gene Wirchenko <genew@ocis.net> - 2012-09-12 18:29 -0700
                Re: can't throw Patricia Shanahan <pats@acm.org> - 2012-09-12 18:34 -0700
                Re: can't throw Arne Vajhøj <arne@vajhoej.dk> - 2012-09-12 21:37 -0400
                Re: can't throw Arne Vajhøj <arne@vajhoej.dk> - 2012-09-12 21:54 -0400
          Re: can't throw Jim Janney <jjanney@shell.xmission.com> - 2012-09-12 11:27 -0600
          Re: can't throw Arne Vajhøj <arne@vajhoej.dk> - 2012-09-12 18:24 -0400
            Re: can't throw Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2012-09-13 22:20 -0700
              Re: can't throw Gene Wirchenko <genew@ocis.net> - 2012-09-14 09:49 -0700
                Re: can't throw Robert Klemme <shortcutter@googlemail.com> - 2012-09-14 20:50 +0200
                Re: can't throw Lew <lewbloch@gmail.com> - 2012-09-14 13:02 -0700
                Re: can't throw Gene Wirchenko <genew@ocis.net> - 2012-09-14 14:06 -0700
                Re: can't throw Gene Wirchenko <genew@ocis.net> - 2012-09-14 13:16 -0700
                Re: can't throw Robert Klemme <shortcutter@googlemail.com> - 2012-09-14 23:07 +0200
                Re: can't throw Lew <lewbloch@gmail.com> - 2012-09-14 14:28 -0700
                Re: can't throw Gene Wirchenko <genew@ocis.net> - 2012-09-16 20:04 -0700
        Re: can't throw Arne Vajhøj <arne@vajhoej.dk> - 2012-09-12 18:16 -0400
          Re: can't throw Lew <lewbloch@gmail.com> - 2012-09-12 23:15 -0700
        Re: can't throw Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-09-14 17:33 -0500
          Re: can't throw Robert Klemme <shortcutter@googlemail.com> - 2012-09-16 15:46 +0200
            Re: can't throw Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-09-16 12:17 -0500
              Re: can't throw Robert Klemme <shortcutter@googlemail.com> - 2012-09-16 22:36 +0200
                Re: can't throw Gene Wirchenko <genew@ocis.net> - 2012-09-16 20:07 -0700
                Re: can't throw Robert Klemme <shortcutter@googlemail.com> - 2012-09-17 07:41 +0200
                Re: can't throw Gene Wirchenko <genew@ocis.net> - 2012-09-17 09:51 -0700
                Re: can't throw Robert Klemme <shortcutter@googlemail.com> - 2012-09-17 21:00 +0200
                Re: can't throw Gene Wirchenko <genew@ocis.net> - 2012-09-17 13:23 -0700
                Re: can't throw Joerg Meier <joergmmeier@arcor.de> - 2012-09-17 18:52 +0200
                Re: can't throw Lew <lewbloch@gmail.com> - 2012-09-17 11:22 -0700
                Re: can't throw Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-09-17 02:52 -0500
                Re: can't throw Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-09-17 02:39 -0500
                Re: can't throw Robert Klemme <shortcutter@googlemail.com> - 2012-09-17 21:02 +0200
  Re: can't throw markspace <-@.> - 2012-09-11 14:28 -0700
  Re: can't throw Arne Vajhøj <arne@vajhoej.dk> - 2012-09-11 21:14 -0400
    Re: can't throw Arne Vajhøj <arne@vajhoej.dk> - 2012-09-12 18:11 -0400
  Re: can't throw Robert Klemme <shortcutter@googlemail.com> - 2012-09-12 08:31 +0200
    Re: can't throw bob smith <bob@coolfone.comze.com> - 2012-09-12 11:40 -0700
      Re: can't throw Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-09-12 15:50 -0400
      Re: can't throw Lew <lewbloch@gmail.com> - 2012-09-12 12:52 -0700
        Re: can't throw Robert Klemme <shortcutter@googlemail.com> - 2012-09-12 23:24 +0200
          Re: can't throw Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-09-12 15:10 -0700
            Re: can't throw Robert Klemme <shortcutter@googlemail.com> - 2012-09-13 23:32 +0200
    Re: can't throw Arne Vajhøj <arne@vajhoej.dk> - 2012-09-12 18:06 -0400
  Re: can't throw Roedy Green <see_website@mindprod.com.invalid> - 2012-09-12 20:55 -0700

csiph-web