<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'><div dir='ltr'>
Hi,<br><br>I want to run some main-thread on the server which periodically checks something, later this will be some watchdog-process.<br><br>How can I reach all channels from that main thread ? <br><br>Snippets:<br><br>....<br> bootstrap.setPipelineFactory(new ChannelPipelineFactory() {<br> public ChannelPipeline getPipeline() {<br> return Channels.pipeline(<br> new BasicFrameDecoder()<br> ,new DiscardServerHandler());<br> }<br> });<br><br> bootstrap.setOption("child.tcpNoDelay", true);<br> bootstrap.setOption("child.keepAlive", true);<br> System.out.print("Binding to " + host + ":" + port + ".\n");<br> bootstrap.bind(new InetSocketAddress(host, port));<br> // Create and start the thread<br> Thread thread = new MainLoopThread();<br> thread.start();<br>....<br><br>///////////////<br><br>public class MainLoopThread extends Thread {<br> // This method is called when the thread runs<br> <br> private Timer timer;<br> private int seconds = 3;<br> <br> <br> public void run() {<br> System.out.println("Thread MainLoop started.");<br> timer = new Timer();<br> timer.schedule(new RemindTask(), seconds * 1000); <br> }<br><br>}<br><br>///////////////<br><br>class RemindTask extends TimerTask {<br> private int iterations = 0;<br> <br> public void run() {<br> System.out.println("Timer [" + iterations + "]");<br> iterations++;<br> <br> // how to reach the channels of the connected users ?<br> <br> <br> }<br>}<br><br>As you can see the RemindTask wants to reach the channels.<br><br><br>In my ServerHandler I keep track of the channels like this:<br><br>static final ChannelGroup channels = new DefaultChannelGroup();<br><br>And the channelConnected event adds a channel to that group and the channelDisconnected event removes it.<br><br>How do I access the ChannelGroup from my thread ? I can't just instantiate the ServerHandler again from my TimerTask and then call some public method of the ServerHandler ? <br><br>Thanks in advance!<br><br><br>                                            </div></body>
</html>