本文介绍了MyBatis中的多线程服务器客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我编写了一个单线程客户端服务器模型,它执行以下操作:
I have coded a single threaded client server model which does following:
- 服务器循环客户端等待..
- 当客户端运行时,它发送当前可用的数据(即一个由逗号分隔的10个字段的字符串)
- 服务器从客户端读取数据并对其解码检查逗号)
- 然后使用mybatis服务器更新数据库。
- Server loops for client waiting..
- When client runs, it sends current data available (i.e. a string which has 10 fields seperated by comma)
- Server reads the data from client and decodes it (simply by checking for comma)
- Then using mybatis server updates database.
这个服务器到多线程的一个,我真的很困惑,看看我在谷歌搜索(即聊天服务器等)发现的一些例子。
Now I want to convert this server to multithreaded one and I am really confused looking at some examples that I found while googling (i.e. chat server etc.).
所以,任何人都可以帮助我
So, can anyone please help me out where exactly to start from to convert server into a multithreaded one?
如果需要,我可以将代码放在这里。
I can post the code here if required.
推荐答案
您可以为每个传入连接启动一个线程。
在此页面的底部,您可以找到一个包含源代码的示例:
You could start a thread for every incoming connection.At the bottom of this page you can find an example with source code: Writing the Server Side of a Socket
这篇关于MyBatis中的多线程服务器客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!