作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想使用线程运行 GUI 以避免卡住问题,如何添加线程来查看?或者您对避免 GUI 卡住问题有什么总体想法吗?
public class Vark {
public static void main(String[] args) {
// Object Creation For the View
VarkView theView = new VarkView();
// Object Creation For the Model
VarkModel theModel = new VarkModel();
// Object Creation For the Controller passing theModel and theView
VarkController theController = new VarkController(theView, theModel);
theView.setVisible(true);
}
}
最佳答案
简单的答案是大部分工作在 GUI 线程上完成,只有时间密集型作业放在单独的线程上(阅读有关创建新线程、Runnable 接口(interface)、ThreadPoolExecutor 和 Callable 接口(interface)的信息)。
一般来说,有很多工作模式。对于初学者来说,它可能是生产者/消费者模式。
与往常一样,线程不要忘记保护共享数据(同步、锁),甚至更好 - 避免在线程之间共享数据:)
关于java - 如何添加线程 MVC 模式 theView 以避免 JFrame 卡住,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22480870/
我想使用线程运行 GUI 以避免卡住问题,如何添加线程来查看?或者您对避免 GUI 卡住问题有什么总体想法吗? public class Vark { public static void m
我是一名优秀的程序员,十分优秀!