Re: concurrency driving me crazy
- From: "Boudewijn Dijkstra" <usenet@xxxxxxxxxxxxxxxxxxx>
- Date: Sat, 10 Dec 2005 23:01:11 +0100
"Andersen" <andersen_800@xxxxxxxxxxx> schreef in bericht
news:439af00d$0$54384$892e7fe2@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Boudewijn Dijkstra wrote:
>> A listing says more than a thousand words. May the source be with us?
>
> Certainly. Certain parts will be missing, but here it is. Search for *** to
> find the place where the problem occurs.
>
> [...]
>
> t1.start();
> t2.start();
> try {
> t1.join();
> t2.join();
> } catch (Exception ex) {
> ex.printStackTrace();
> }
>
> // *** This is were I get the fishy behaviour.
>
> System.out.println();
> long c1 = app1.getCount();
> long c2 = app2.getCount();
> assertEquals(c1, c2);
> assertEquals(c1, ROUTECOUNT);
> }
>
> [...]
Are you sure the final println isn't happening at the *beginning*?
When sending messages over sockets, they may pass through several threads
and/or processes before arriving at the destination. Because the messages are
passed asynchronously (=without waiting for it to get delivered), t1 and t2
will probably finish very quickly. So when the counts are queried, some
messages will still be queued somewhere and the assertion will fail.
.
- Follow-Ups:
- Re: concurrency driving me crazy
- From: Andersen
- Re: concurrency driving me crazy
- References:
- concurrency driving me crazy
- From: Andersen
- Re: concurrency driving me crazy
- From: Boudewijn Dijkstra
- Re: concurrency driving me crazy
- From: Andersen
- concurrency driving me crazy
- Prev by Date: can struts read hebrew from property files?
- Next by Date: Re: Object.wait()
- Previous by thread: Re: concurrency driving me crazy
- Next by thread: Re: concurrency driving me crazy
- Index(es):
Relevant Pages
|