MyBatis中的多线程服务器客户端 [英] Multithreaded Server Client in MyBatis

查看:124
本文介绍了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

这篇关于MyBatis中的多线程服务器客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆