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


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

Re: Making one or more threads wait for another to produce a value or fail

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.linkpendium.com!news.linkpendium.com!newsfeeds.ihug.co.nz!lust.ihug.co.nz!ihug.co.nz!not-for-mail
From Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand>
Newsgroups comp.lang.java.programmer
Subject Re: Making one or more threads wait for another to produce a value or fail
Followup-To comp.lang.java.programmer
Date Wed, 01 Jun 2011 12:33:39 +1200
Organization Geek Central
Lines 72
Message-ID <is41d4$s5p$1@lust.ihug.co.nz> (permalink)
References <alpine.DEB.2.00.1105311443530.28134@urchin.earth.li>
NNTP-Posting-Host 118-92-86-36.dsl.dyn.ihug.co.nz
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Trace lust.ihug.co.nz 1306888420 28857 118.92.86.36 (1 Jun 2011 00:33:40 GMT)
X-Complaints-To abuse@ihug.co.nz
NNTP-Posting-Date Wed, 1 Jun 2011 00:33:40 +0000 (UTC)
User-Agent KNode/4.4.11
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:4834

Followups directed to: comp.lang.java.programmer

Show key headers only | View raw


In message <alpine.DEB.2.00.1105311443530.28134@urchin.earth.li>, Tom 
Anderson wrote:

> Penelope is a widow, or at least her husband isn't around any more (she's
> not sure which; long story). There are 108 suitors who would like to marry
> her. She hasn't decided which one she'll marry. So, the 108 suitors are
> sitting about waiting for her to decide. It's possible that instead of
> deciding to marry one of them, she'll deliver some other, exceptional,
> verdict (eg "turns out my husband is still alive, and will now murder you
> all").
> 
> Penelope is a thread, as are her suitors. Penelope has plenty to do after
> she delivers her verdict, so the verdict is not a return value - it's a
> value she'll pass to a method.

procedure penelope_and_her_suitors is

    subtype verdict_string is
        string(1 .. 12);

    protected verdict is

        entry deliver(v : in verdict_string);
        entry obtain(v : out verdict_string);

    private
        v : verdict_string;
        got_v : boolean := false;
    end verdict;

    protected body verdict is

        entry deliver(v : in verdict_string) when not got_v is
        begin
            verdict.v := v;
            got_v := true;
        end deliver;

        entry obtain(v : out verdict_string) when got_v is
        begin
            v := verdict.v;
        end obtain;

    end verdict;

    task penelope is
    end penelope;

    task type suitor is
    end suitor;

    task body penelope is

    begin
        --- think about what verdict to deliver
        verdict.deliver("you all die "); -- or whatever
    end penelope;

    task body suitor is

        the_verdict : verdict_string;

    begin
        verdict.obtain(the_verdict);
        -- do whatever with it
    end suitor;

    suitors : array (1 .. 108) of suitor;

begin -- penelope_and_her_suitors
    null; -- wait for all the fun to finish
end penelope_and_her_suitors;

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


Thread

Making one or more threads wait for another to produce a value or fail Tom Anderson <twic@urchin.earth.li> - 2011-05-31 15:00 +0100
  Re: Making one or more threads wait for another to produce a value or fail Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2011-05-31 07:14 -0700
    Re: Making one or more threads wait for another to produce a value or fail Tom Anderson <twic@urchin.earth.li> - 2011-05-31 16:46 +0100
      Re: Making one or more threads wait for another to produce a value or fail Deeyana <d.awlberg@hotmail.invalid> - 2011-05-31 19:23 +0000
        Re: Making one or more threads wait for another to produce a value or fail Tom Anderson <twic@urchin.earth.li> - 2011-06-01 22:12 +0100
      Re: Making one or more threads wait for another to produce a value or fail Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2011-05-31 20:45 -0700
        Re: Making one or more threads wait for another to produce a value or fail Patricia Shanahan <pats@acm.org> - 2011-05-31 21:37 -0700
          Re: Making one or more threads wait for another to produce a value or fail Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2011-06-01 07:18 -0700
            Re: Making one or more threads wait for another to produce a value or fail Patricia Shanahan <pats@acm.org> - 2011-06-01 09:01 -0700
        Re: Making one or more threads wait for another to produce a value or fail Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-06-01 16:40 +1200
          Re: Making one or more threads wait for another to produce a value or fail "John B. Matthews" <nospam@nospam.invalid> - 2011-06-01 11:22 -0400
            Re: Making one or more threads wait for another to produce a value or fail Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-06-02 10:15 +1200
              Re: Making one or more threads wait for another to produce a value or fail "John B. Matthews" <nospam@nospam.invalid> - 2011-06-01 21:38 -0400
        Re: Making one or more threads wait for another to produce a value or fail Tom Anderson <twic@urchin.earth.li> - 2011-06-01 22:07 +0100
          Re: Making one or more threads wait for another to produce a value or fail Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2011-06-01 22:46 -0700
  Re: Making one or more threads wait for another to produce a value or fail markspace <-@.> - 2011-05-31 08:26 -0700
    Re: Making one or more threads wait for another to produce a value or fail Tom Anderson <twic@urchin.earth.li> - 2011-05-31 19:13 +0100
  Re: Making one or more threads wait for another to produce a value or fail Patricia Shanahan <pats@acm.org> - 2011-05-31 09:06 -0700
    Re: Making one or more threads wait for another to produce a value or fail Paul Cager <paul.cager@googlemail.com> - 2011-05-31 10:08 -0700
      Re: Making one or more threads wait for another to produce a value or fail Patricia Shanahan <pats@acm.org> - 2011-05-31 10:39 -0700
        Re: Making one or more threads wait for another to produce a value or fail Paul Cager <paul.cager@googlemail.com> - 2011-05-31 16:24 -0700
  Re: Making one or more threads wait for another to produce a value or fail Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-06-01 12:33 +1200
    Re: Making one or more threads wait for another to produce a value or fail "John B. Matthews" <nospam@nospam.invalid> - 2011-06-01 00:38 -0400
  Re: Making one or more threads wait for another to produce a value or fail markspace <-@.> - 2011-06-02 14:10 -0700
    Re: Making one or more threads wait for another to produce a value or fail markspace <-@.> - 2011-06-02 14:25 -0700
    Re: Making one or more threads wait for another to produce a value or fail Patricia Shanahan <pats@acm.org> - 2011-06-02 14:43 -0700

csiph-web