有关流程之间相互作用的问题 [英] question about interaction between processes

查看:131
本文介绍了有关流程之间相互作用的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在Visual Basic 2008 Express Edition中的计时有问题.

我的软件有2个进程,它们使用相同的变量进行交互.它们都是我在启动时打开的线程(Threading.Thread),它们在循环时不断执行包含在其中的某些操作.
此外,我插入了秒表来测量执行过程中的每个时间间隔.

采取第一个措施后,我注意到两个进程都需要300-400ms的时间才能在while周期内完成代码.

因此,我将第二个线程的代码移到了第一个线程的while周期中.这样,两个部分的执行在单个过程中是顺序执行的.

在第二个措施之后,我注意到两个过程都需要5-6ms才能完成相同的代码(快60倍).怎么可能呢?
是由当代对相同变量的访问引起的吗?是Windows进程管理(优先级)引起的问题吗?

预先感谢

Matteo

Hi,

I have a problem with timing in visual basic 2008 express edition.

My software has 2 processes that interact using the same variables. Both of them are threads (Threading.Thread) that i open at the startup, whose keep executing some operation included into they respective while cycle.
Furthermore I inserted a stopwatch to measure every time interval during execution.

After the first measure, I noticed that both process needs 300-400ms to complete the code inside the while cycle.

So I moved the code of second thread into the while cycle of the first thread. In this way the execution of both part is sequential in a single process.

After the second measure, I noticed that both process needs 5-6ms to complete the same code (is like 60 times faster). How is it possible?
Is it caused by the contemporary access to the same variables? is it a problem caused by windows process management (priority)?

Thanks in advance

Matteo

推荐答案

我认为我们需要了解您如何管理代码中的线程来回答您的问题.

I think we would need to see how you are managing the threads in your code to answer your question.

无论如何,我看不到您所描述的多个进程,而是具有多个线程的单个进程.

In any event, I do not see multiple processes in what you describe, but a single process with multiple threads.


这篇关于有关流程之间相互作用的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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