tk借助Thread包实现多线程实例
来源:互联网 发布:dir python 编辑:程序博客网 时间:2024/05/02 13:23
对于有需求进行多线程操作,或者有界面相关操作的运算以及后台处理情况,可以通过多现场操作。
一下例子:Creating a separate thread to perform a lengthy operation
package require Thread# Create a separate thread to search the current directory# and all its subdirectories, recursively, for all files# ending in the extension ".tcl". Store the results in the# file "files.txt".thread::create { # Load the Tcllib fileutil package to use its # findByPattern procedure. package require fileutil set files [fileutil::findByPattern [pwd] *.tcl] set fid [open files.txt w] puts $fid [join $files \n] close $fid}# The main thread can perform other tasks in parallel...
对于需要在{}中体现变量数据的情况,可以通过如下结构实现:
thread::create [list exec app.exe]
以下实例:在应用中创建多线程Creating several threads in an application
package require Threadputs "*** I'm thread [thread::id]"# Create 3 threadsfor {set thread 1} {$thread <= 3} {incr thread} { set id [thread::create { # Print a hello message 3 times, waiting # a random amount of time between messages for {set i 1} {$i <= 3} {incr i} { after [expr { int(500*rand()) }] puts "Thread [thread::id] says hello" } }] ;# thread::create puts "*** Started thread $id"} ;# forputs "*** Existing threads: [thread::names]"# Wait until all other threads are finishedwhile {[llength [thread::names]] > 1} { after 500}puts "*** That's all, folks!"
0 0
- tk借助Thread包实现多线程实例
- Runnable和Thread实现多线程区别实例
- Python 多线程 Thread包
- 借助Xutils实现多线程下载
- 多线程Thread类实例
- 利用Thread子类在程序中实现多线程实例
- 4.多线程实例:thread.c
- 4.多线程实例:thread.c
- JAVA 多线程Thread简单实例
- 借助WebService实现多线程上传文件
- 借助WebService实现多线程上传文件
- 借助WebService实现多线程上传文件
- 借助WebService实现多线程上传文件
- 借助WebService实现多线程上传文件
- 借助WebService C#实现多线程上传文件
- php借助linux实现多线程1
- java Thread:利用Thread类实现多线程
- 第一个ajax小实例(借助dwr包)
- JDK5新特性:可变参数方法
- 一道面试题的分析
- 最简单的TCP程序
- 【关于简历】——-从简历看出一个人的性格
- 最简单的UDP程序
- tk借助Thread包实现多线程实例
- 用jquery控制表格奇偶行及活动行颜色
- 虚拟主机TOMCAT配置
- Java连接sqlite数据库
- Java连接mysql数据库
- 用户登录注册案例分析
- 图像边缘检测、角点特征检测以及SURF特征提取
- Mysql中的事务
- 使用ajax验证用户名重复