[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Why to interrupt blocked socket? - Re: No message for 6 months
Barry,
I would suggest to replace sleep(N) with wait(N), because calling sleep()
does not release the current lock; calling wait() does.
Welch,
Nice to hear your quick response. Since socket is at a very low level,
somehow I feel pooling is inevitable. I was thinking about letting
the thread wait() on an object, waiting for a call back. However, a
call-back won't be detected unless pooling is carried out.
Shengru
bmc wrote:
> I find that windoze seems to reschedule in 200ms intervals - too long! I do (pseudo-code):
>
> while( x.available() == none ) { Thread.sleep( N ); }
> x.read();
>
> where N is a small integer (ms in Java) (1 if I'm really needing performance). It, obviously takes some processor time - but responds MUCH more quickly than a blocking call (on windoze, at least).
>
> This would also give you a repeatecd wake-up to check a flag by way of interrupt.
>
> Barry.
>
> Barry M Cook,
> CTO,
> 4Links Limited.
>
> -----Original Message-----
> From: Shengru Tu [SMTP:shengru@xxxxxxxxxx]
> Sent: Thursday, March 06, 2003 6:33 PM
> To: occam-com@xxxxxxxxx; richard.beton@xxxxxxxxxx; java-threads@xxxxxxxxx
> Cc: java-threads@xxxxxxxxx
> Subject: Why to interrupt blocked socket? - Re: No message for 6 months
>
> Why do you let any thread be block at any socket, more accurately,
> at any stream? To avoid being blocked, Method available() of the
> stream should be called before read(XXX) in a synchronized method
> or block.
>
> Shengru
>
> >From: "Beton, Richard" <richard.beton@xxxxxxxxxx>
> >To: occam-com mailing list <occam-com@xxxxxxxxx>
> >Cc: Java-Threads Mailing List <java-threads@xxxxxxxxx>
>
> ..
>
> >Ping! Yep, still here and busy as ever.
> >
> >Am currently happily 'struggling' with a bit of JCSP. One thread reads
> >from a socket and may be blocked and I want to be able to interrupt it
> >cleanly. This is more difficult than I expected, so suggestions are
> >welcome (JCSP gets upset if you interrupt your threads, and with some
> >justification). Otherwise my bodge will have to suffice.
> >
> >Rick :-)
> >
>
> **----------------------------------------------------------------------**
> | Dr. Shengru Tu, Associate Professor | shengru@xxxxxxxxxx |
> | Computer Science Department | (504) 280 - 7108 (Voice) |
> | University of New Orleans | - 7228 (Fax) |
> | 2000 Lakeshore Drive | |
> | New Orleans, LA 70148 | http://www.cs.uno.edu/~shengru |
> **----------------------------------------------------------------------**
>
> ------------------------------------------------------------------------
>
> Part 1.2 Type: application/ms-tnef
> Encoding: base64