This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
nio.Selector behavior?
- From: Erik J Pearson <erik dot pearson at comcast dot net>
- To: java at gcc dot gnu dot org
- Date: 28 Oct 2003 22:31:27 -0800
- Subject: nio.Selector behavior?
- Organization:
(I always try to search the archives to see if this
has been pointed out. Sorry if it's a duplicate...)
While doing some testing, I was curious if a Selector
could be used for sleeping, like select() when it called
with null parameters except the timeout:
import java.nio.channels.*;
public class Select {
public static void main(String Args[]) {
try {
Selector mySelector = Selector.open();
// No registered channels
mySelector.select(10000);
}
catch (java.io.IOException IOe) {}
}
}
Strangely, Sun's java 1.4.2 gives different
results than gij/gcj 3.3.2:
$ time java -cp . Select
real 0m10.194s
user 0m0.130s
sys 0m0.040s
$ time gij Select
real 0m0.121s
user 0m0.100s
sys 0m0.010s
Without any registered channels gij doesn't try
but java does.
What is the correct behavior?
Thanks in advance.
--erikp--