开发者

Should I use Threads for a Task Processor?

I am building a service 开发者_StackOverflow中文版that involves node(s) pulling tasks from a task server. To carry out the task is pretty simple, it just pulls some stuff from a DB and sends it to a SMTP server. Right now it pulls like 20 tasks I think at a time, loops through and finishes them, then goes and asks for more tasks.

Since the program itself isn't very resource intensive (it's like 25 MB of RAM when processing a task), would it make sense to use Threads or will the performance still be the same as if it weren't using it. The nodes are 256 MB RAM VM's, and the service is written in Java.


No. Use an Executor; it might use threads internally but you won't get dirty in the process. Example code: http://programmingexamples.wikidot.com/executorservice

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜