MyBatis中的多线程服务器客户端

问题描述:

我编写了一个单线程客户端服务器模型,它执行以下操作:

I have coded a single threaded client server model which does following:


  1. 服务器循环客户端等待..

  2. 当客户端运行时,它发送当前可用的数据(即一个由逗号分隔的10个字段的字符串)

  3. 服务器从客户端读取数据并对其解码检查逗号)

  4. 然后使用mybatis服务器更新数据库。

  1. Server loops for client waiting..
  2. When client runs, it sends current data available (i.e. a string which has 10 fields seperated by comma)
  3. Server reads the data from client and decodes it (simply by checking for comma)
  4. 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