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
}
The reason why I want to do it is to make the logic-side code clear and easy
to handle.
We often do this way when we are developing MMO Games. ;)
On Fri, Mar 13, 2009 at 12:02 AM, Thomas Harning Jr. <[email protected]>wrote:
> On Thu, Mar 12, 2009 at 10:45 AM, Oscar <[email protected]> wrote:
> > hi all-
> > To simplify the business-side code, I wanna run the messageReceived in
> the
> > main thread.
> >
> > I know I could put all the received object to the unique queue, and then
> > the main thread fetch and handle the message in the queue.
> >
> > Any better way?
> If this sort of mechanism is what you absolutely want, then I suggest
> having the messageReceived event post the work-item to an Executor (in
> your case, an instance created by
> Executors.newSingleThreadExecutor()).
>
> That way all work is done in a single thread.
>
> If you want things run in the main thread... then you're "stuck" with
> starting the Mina queue and using a BlockingQueue implementation.
>
> --
> Thomas Harning Jr.
>