-
Threads in JavaFX
Hello,
I try to develop a chat client with javafx, I have a java class that implements Runnable. When I create an instance this class since main.fx, the class performs 5 or 6 loop then the thread dies automatically. I have no idea regarding this problem. Also, do I have to implement threads in javafx in a different way or as i would to do in java? Any help will interest me. Thank you.
-
Re: Threads in JavaFX
You can try the following part of code
Code:
public void run() (
while (Thread.currentThread().isAlive())(
/ / reception of message from the server
)
)
Infinite loops, it is nice but it may need to do a sleep () system to let the story breathe and allow other threads to run. But hey I guess when you expect the server info should be ca call blocks? So it can allow time to do other things during the crash.
-
Re: Threads in JavaFX
To call another Thread and especially to execute Java code from JavaFX must use the class JavaTaskBase and create a java class that extends RunnableFuture.
Here is the code showing the same
Code:
def test: JavatestBase JavatestBase =(
/ ** * (@ inheritDoc) * /
public override function create(): JavatestBase (
MyRunnable()
)
)
test.start();
-
Re: Threads in JavaFX
If you need you can try the following code as an alternative, this is just the syntax of the code you will need to insert the code manually.
Here is the code
Code:
public class test implements RunnableFuture (
/ ** * (@ inheritDoc) * /
@ Override
public void run() throws Exception (
[...]
)
)
Page generated in 1,711,775,821.36239 seconds with 11 queries