如何在Task中设置Var?(How to set a Var from inside a Task?)

编程入门 行业动态 更新时间:2024-10-27 19:16:01
如何在Task中设置Var?(How to set a Var from inside a Task?)

首先,我是JavaFX的新手,很抱歉,如果这个问题很愚蠢。 如何从任务中获取返回对象?

继承我的问题:

我想从模拟中获取一个对象列表。 模拟的延迟时间为1到5秒。 但我不想要,我的GUI在这个时候冻结了。

在Java.Swing中,使用Thread很容易,但就我所知,JavaFX具有Tasks。

我已经阅读了很多教程,但他们返回的文本属性。 所以这是我的问题:如何使用任务/线程(在我的情况下为List)中的计算结果设置Object的值

谢谢。

First of all I'm new at JavaFX, so sorry if this question is stupid. How can I get an return Object from a Task?

Heres my Problem:

I want to get a List of Objects from a Mock. The Mock has a delay from 1 up to 5 seconds. But I dont want, that my GUI freeze in this time.

In Java.Swing it was easy with an Thread, but JavaFX has, as far as I know, Tasks.

I've read much tutorials, but everywhere they return a text property. So here is my question: how can I set the value of an Object with the result of the calculation from a Task/Thread (in my case a List)

Thank you.

更多推荐

本文发布于:2023-07-08 01:01:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1070200.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在   Task   set   Var

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!