Quote
A thread blocked in one of the select() or select(long) methods may be interrupted by some other thread in one of three ways:
By invoking the selector's wakeup method,
By invoking the selector's close method, or
By invoking the blocked thread's interrupt method, in which case its interrupt status will be set and the selector's wakeup method will be invoked.
The close method synchronizes on the selector and all three key sets in the same order as in a selection operation.
By invoking the selector's wakeup method,
By invoking the selector's close method, or
By invoking the blocked thread's interrupt method, in which case its interrupt status will be set and the selector's wakeup method will be invoked.
The close method synchronizes on the selector and all three key sets in the same order as in a selection operation.
The first part says that selector.close() will interupt the select(), but then it says that close() locks on the same keys as select(), meaning that it will wait forever until the select() is complete before closing. So which should it be. What I am seeing is that close() does not interrupt the select, but waits for select to finish. Is this a bug, or by design?
Then down below in the close() method it states:
Quote
If a thread is currently blocked in one of this selector's selection methods then it is interrupted as if by invoking the selector's wakeup method.
Any uncancelled keys still associated with this selector are invalidated, their channels are deregistered, and any other resources associated with this selector are released.
Any uncancelled keys still associated with this selector are invalidated, their channels are deregistered, and any other resources associated with this selector are released.
However, this is not the case. Simple example:
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | import java.nio.channels.Selector; |
This is on windows running 1.4.2beta and 1.4.2_01
Any feedback. I just checked java bug report and didnt see this anywhere. It seems too obvious to be wrong.



