自定义线程 [英] Customise Threading

查看:68
本文介绍了自定义线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

专家们,我想问你有关线程的问题.
我们可以通过自定义线程来创建一些线程吗,我的意思是我可以通过例如设置xml中的线程数来创建某个线程,因此我的应用可以通过读取此xml中的线程数来生成某个线程.请给我例子...:(

Hi experts, i wanna ask you about threading..
Can we make some thread by customise the thread, I mean that I can make some thread by set the number of thread in xml for example, so my app can generate some thread by reading the number of threading in this xml. Give me the example please... :(

推荐答案

您的问题措辞不好,所以我不确定您在说什么.是的,您可以从XML文件中读取一个整数,然后创建那么多线程.您具体遇到什么问题?您不知道如何创建线程吗?如何读取XML文件?如何使用for循环?知道如何做所有这些事情,那么您应该能够完成此任务.
Your question is poorly phrased, so I''m not exactly sure what you''re talking about. Yes, you can read in an integer from an XML file then create that many threads. What problem are you having specifically? Do you not know how to create a thread? How to read an XML file? How to use a for loop? If you know how to do all those things, then you should be able to accomplish this task.




由于您知道如何完成所有单个任务,因此这里有一些伪代码可以为您提供实现问题的思路:

Hi,

Since you know how to accomplish all the single tasks here is some Pseudo code for you that may give you an idea how to implement your problem:

int nThreadCount = ReadXMLInteger(); //read an integer number from your xml file
for(int i = 0; i < nThreadCount; i++)
{
  CreateThread();
}


这篇关于自定义线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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