多线程 [英] Multiple Threading

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

问题描述

我知道如何创建线程,但是我不知道如何使用键盘键控制线程.

按下"t"时,线程1应该启动并在屏幕的左上角显示运动

第二次按下"t"时,线程2应该启动并在屏幕的右上角显示运动

按下"x"时,线程1应该停止.

在第二次按"x"时,线程2应该停止.

i know how to create thread but i dont know how to controll this using keyboard keys.

On pressing ‘t’ thread 1 should start and show movement on upper left corner of screen

On pressing ‘t’ second time, thread 2 should start and show movement on upper right corner of screen

On pressing ‘x’ thread 1 should stop.

On pressing ‘x’ second time thread 2 should stop.

推荐答案

当您想在网页上显示此类内容时,必须在客户端上使用javascript.您可以使用setTimeout模仿某种线程功能.每次输入给定方法时,这都是该线程的某种时间片(以某种协作的方式).

看看这里的例子:
" http://www.sislands.com/coin70/week3/bball.htm [ ^ ]

祝你好运!
When you want to show these kind of stuff on a web page you must use javascript on the client. You can use setTimeout to mimic somekind of threading functionality. Each time you enter the given method, this is some sort of time slice for that thread (in a somewhat cooperative fashion).

Have a look here for an example:
"http://www.sislands.com/coin70/week3/bball.htm[^]

Good luck!


这篇关于多线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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