Periodic TimerTask in netty

magiceye magiceye at 163.com
Mon Sep 5 04:49:24 EDT 2011


If there is no timer task, does user need to consider problem like: should I
mark this data of this business class to be volatile? Should I add
synchronized keywords on this member function? Generally, the answer is No.
That is the advantage of Executionhandler. These business object is
concurrent without user care multi-thread problem and this is a key feature
of a framework.
But, if there are some timer task to access those business object(also
accessed by threads in ExecutionHandler), the advantage is gone. You need to
consider multi-thread problem just because you can not uitilize netty's
inside thread to execute these timer tasks. I mean "gone" is in the view of
design class *which can be concurrent.* That don't need to care if there is
no timer task.

Of course netty can not aware any business logic, but any network must care
the "trigger point" of business logic. For most use case, the "trigger
point" is recv a client package, and framework gives user a chance to run
their business logic. In some application, not all business logic was
triggered by a client package arriving. Image a MMO game server, a NPC walk
around a house, the walk action was not triggered by any client package,
because it is not player control unit. The only way is start a timer task,
but, if doing so, objects shared by netty's thread and timer task thread
needs to be carefully designed to be concurrent. If those object is many,
then advantage of ExecutionHandler is insignificant. That can be saved if
netty support something. 

--
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Periodic-TimerTask-in-netty-tp6756465p6760214.html
Sent from the Netty User Group mailing list archive at Nabble.com.


More information about the netty-users mailing list