This is simple multi-threading program that draws circles and rectangles. Each shape is handle by individual thread that created every time you press start button. Using sleep method on each thread we can change the speed of each shape.
I have used VS.NET to implement this program. Double click on Thread_Example.Zip and extract all the files and folders to a folder in C drive.
其中,基类Shapes.cs:
代码如下:
继承Shapes的2个继承类:Rectangle和Circle类定义如下:
和
主界面如下:
全局变量定义如下:
注意其中的:
退出部分代码如下:
开始按钮代码 如下:
当中对线程的定义部分如下: