Results 1 to 4 of 4

Thread: Threads in JavaFX

  1. #1
    Join Date
    Mar 2010
    Posts
    303

    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.

  2. #2
    Join Date
    Mar 2010
    Posts
    197

    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.

  3. #3
    Join Date
    Dec 2009
    Posts
    263

    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();

  4. #4
    Join Date
    Dec 2009
    Posts
    192

    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 (
        [...]
      )
    )

Similar Threads

  1. What would be a limit for threads per day?
    By Cauvery in forum Technology & Internet
    Replies: 7
    Last Post: 21-07-2011, 11:47 PM
  2. Threads in Java
    By Addis in forum Guides & Tutorials
    Replies: 4
    Last Post: 18-02-2010, 11:47 AM
  3. threads concept in java
    By vijji191 in forum Software Development
    Replies: 2
    Last Post: 30-11-2009, 02:44 PM
  4. Syntax for Creating and Terminating C# Threads
    By Jesus2 in forum Software Development
    Replies: 3
    Last Post: 12-11-2009, 05:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •