[722] in java-interest

home help back first fref pref prev next nref lref last post

Re: Threads and select ()

daemon@ATHENA.MIT.EDU (Nathan Abramson)
Mon Jul 17 16:26:09 1995

From: Nathan Abramson <arista@art.redstar.com>
Date: Mon, 17 Jul 1995 14:50:53 -0400
To: jpayne@starwave.com (Jonathan Payne), arista@art.redstar.com
Cc: java-interest@java.Eng.Sun.COM, arista@art.redstar.com

At 11:26 AM 7/17/95 -0700, Jonathan Payne wrote:
>> 
>> 1) Is the thread multitasking preemptive, or cooperative?

>Higher priority threads preempt lower priority ones.  Threads at the
>same priority do not preempt, so that's why yield() is there.
>

I hadn't thought of that.  It does make sense (although it is a
bit annoying).

>> 2) There is a function to put a thread to sleep for a certain length of
>>    time.  But is there a way for a thread to sleep while waiting for
>>    file descriptor activity, ala UNIX select ()?

>You can block on read(), which implies a separate thread for each
>socket.  Which may or may not be bad depending one what you're trying
>to do.
>

Would that actually work?  I would think that the first thread to
execute read() would block and stop all the other threads before they
could even execute read().

>I wanted to implement select() a while ago and mentioned it to the
>java team but they blew me off, so I blew it off.

It seems to me that select() would best be in the interpreter.
That way the interpreter could figure out which Threads were waiting
for what, with what timeouts, and block accordingly.  Otherwise,
you'd have to make some kind of event loop in your Java program
with a select() in it, which was what I thought the Java designers were
trying to eliminate.

Too bad the Java folks didn't take it up.

Nathan

-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post