java - 如何一次运行 2 个特定线程?像 platform.runLater() 和其他一些线程
问题描述
我的线程方法看起来像,
public void run(){
int loop=100;
int time=5;
long StartTime = System.currentTimeMillis() / 1000;
for(int i=0;i<loop;i++){
Platform.runLater(new Runnable() {
@Override
public void run() {
r2.setWidth(r2.getWidth()+1);
}
});
try{
Thread.sleep(100);
if((time < ((System.currentTimeMillis() / 1000) - StartTime)))
loop=0;
}
catch(Exception e){
}
}
}
在我的代码的某个地方,我创建了如下线程。
CustomThread thread[]=new CustomThread[3];
double len[]={30,60,90};
for(int i=0;i<thread.length;i++){
thread[i]=new CustomThread(len[i]);
thread[i].start();
/* try{
thread[i].join();
}
catch(Exception e){}*/
}
我希望线程[i] 完成它的执行,然后其他线程[i+1] 将完成它的执行。通过线程[i].join(); 我希望其他线程停止执行此线程,除了 platform.runLater() 线程,当我调用 join() 时该线程停止。总体而言,我希望 platform.runLater() 与当前线程连续执行。有什么建议么 ?
解决方案
推荐阅读
- wordpress - 如何停止将外部 http 链接重定向到 WP 页面上的 https
- asp.net - Entity frame work6.0.0.0 中的错误:未使用 Ignore 方法或 NotMappedAttribute 数据注释明确排除类型
- javascript - Javascript map 函数返回空值
- python - 使用 XGBoost 在 PyCharm 上以退出代码 -1073740791 (0xC0000409) 完成的过程
- javascript - 将输入与因子绑定(v-model)
- vb.net - 使用 Char 字典有用吗?
- postgresql - 如何使用 postgresql 查询在表名中添加双引号?
- java - Dagger - MissingBinding 贴图
,提供者 > 如果没有 @Provides-annotated 方法,则无法提供 - python - 如何在 Python 中获取目录和子文件夹中的一些(5)文件列表?
- c - libcrt 源在 VS2017 中的位置?