public class SelectedSelector extends Selector
| 构造器和说明 |
|---|
SelectedSelector(Selector selector) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
close() |
Selector |
getSelector() |
boolean |
isOpen() |
Set<SelectionKey> |
keys() |
SelectorProvider |
provider() |
void |
rebuildSelector()
新建一个selector来解决空轮询bug
|
SelectionKey |
register(SelectableChannel channel,
int op)
同步, 保证多个线程调用register不会出现问题
|
SelectionKey |
register(SelectableChannel channel,
int op,
Object att) |
int |
select() |
int |
select(long timeout) |
Set<SelectionKey> |
selectedKeys() |
int |
selectNow() |
Selector |
wakeup() |
public SelectedSelector(Selector selector)
public Selector getSelector()
public SelectionKey register(SelectableChannel channel, int op) throws ClosedChannelException
channel - op - ClosedChannelExceptionpublic SelectionKey register(SelectableChannel channel, int op, Object att) throws ClosedChannelException
public SelectorProvider provider()
public Set<SelectionKey> keys()
public Set<SelectionKey> selectedKeys()
selectedKeys 在类中 Selectorpublic int selectNow()
throws IOException
selectNow 在类中 SelectorIOExceptionpublic int select(long timeout)
throws IOException
select 在类中 SelectorIOExceptionpublic int select()
throws IOException
select 在类中 SelectorIOExceptionpublic void close()
throws IOException
close 在接口中 Closeableclose 在接口中 AutoCloseableclose 在类中 SelectorIOExceptionpublic void rebuildSelector()
Copyright © 2021. All rights reserved.