Thanks. I used ConcurrentLinkedQueue in the demo.;) TH, Could I ask you a question?
Assuming we are using ExecutorFilter to implement the mechanism, that is, all the logic code runs in messageReceived. if one piece of logic code costs a lot of time, does it influence the NIO threads (named NioProcessor-n)? On Fri, Mar 13, 2009 at 12:41 AM, Thomas Harning Jr. <[email protected]>wrote: > On Thu, Mar 12, 2009 at 12:13 PM, Oscar <[email protected]> wrote: > > Thanks for you reply.I've finished the rough version, running all the > > business-side code in the main thread. > > > > void main() > > { > > // initialize all the mina stuff > > > > //fetching the message from the queue > > } > > > > > > void messageReceived(...) > > { > > // put the message into the queue. > > // need to lock the queue > > } > Note on implementation: Use a blocking queue, that way all thread > safety is managed for you... as well as the Main thread gets simple. > > (see: > http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/BlockingQueue.html > ) > > Example without using generics... > BlockingQueue queue = new LinkedBlockingQueue(); > > void main() { > // Start mina > while(true) { > process(queue.take()); > } > } > > void messageReceived(...) { > queue.put(message); > } > -- > Thomas Harning Jr. >
