📄 main.pas
字号:
{******************************************************************************}
{红绿灯}
{02162323}
{ 龙涛 }
{******************************************************************************}
unit main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, Unit1, Unit2, Unit3, Unit4, jpeg;
type
TForm1 = class(TForm)
Image1: TImage;
Image2: TImage;
Image3: TImage;
Shape1: TShape;
Shape2: TShape;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
flag: boolean;
thread: Tthread1;
thread2: Tthread2;
thread3, thread4: Tthread3;
BUSStop: Tstop;
implementation
{$R *.dfm}
{卡车与小车 线程}
procedure TForm1.Button1Click(Sender: TObject);
begin
thread := Tthread1.Create(true);
thread2 := Tthread2.Create(true);
BUSStop := Tstop.Create(true);
thread.Resume;
thread2.Resume;
BUSStop.Resume;
Button1.Caption:='汽车行使中...';
Button1.Enabled:=false;
end;
{交通灯}
procedure TForm1.FormCreate(Sender: TObject);
begin
flag := true;
thread3 := Tthread3.Create(false, shape1, true);
thread4 := Tthread3.Create(false, shape2, false);
BUSStop := Tstop.Create(true);
end;
{释放所有线程}
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
thread.Terminate;
thread2.Terminate;
thread3.Terminate;
thread4.Terminate;
busstop.Terminate;
thread.FreeOnTerminate:=true;
thread2.FreeOnTerminate:=true;
thread3.FreeOnTerminate:=true;
thread4.FreeOnTerminate:=true;
busstop.FreeOnTerminate:=true;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -