This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

nio.Selector behavior?


(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--




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]