2010-06-21 233 views

回答

2

你有可能需要多线程。你可以从about.com

+0

thanx的链接...它的一个很好的开始.. – 2010-06-21 08:38:03

3

它使用线程完成。然而,这是一个高级课题,在开始使用线程之前,您最好先学习编程的基础知识。

+0

+1为“高级话题”。 OP可能甚至不想并行执行,但这似乎是被问到的。 – 2010-06-21 14:48:13

7

假设德尔福2009年或以上,并使用OmniThreadLibrary

uses OtlParallel; 

var 
    aRes: integer; 
    bRes: integer; 

begin 
    Parallel.Join(
    procedure begin 
     aRes := a(); 
    end, 
    procedure begin 
     bRes := b(); 
    end); 
end. 

或者对谁不喜欢匿名函数较真:

uses OtlParallel; 

var 
    aRes: integer; 
    bRes: integer; 

procedure CalcA; 
begin 
    aRes := a(); 
end; 

procedure CalcB; 
begin 
    bRes := b(); 
end; 

begin 
    Parallel.Join(CalcA, CalcB); 
end. 

(它的工作工作如果CalcA和CalcB是方法而不是简单的程序,则相同。)

正如其他人所说,多线程领域ng编程充满危险。确保你的两个函数不修改相同的结构,不将数据输出到同一目的地,最重要的是,他们没有以任何方式使用GUI。

+0

你不是说**不**修改相同的结构? – afrazier 2010-06-21 12:44:23

+0

@afrazier:当然!感谢您的更正。 – gabr 2010-06-21 18:51:47

相关问题