Why almost all javafx methods must be called from the thread of the application?

I have a pretty big 3D scene that is refreshed every few seconds.

It takes a while to update the scene, and I wanted to do it in a background thread.

Problem is that almost every approach I take requires the application-fx thread.

Now, I understand that change the UI itself must be called in the application thread, so I tried a different approach:

Create a new group, add all the nodes (which takes the greatest amount of time) and update the component root of the view with the new group.

I assumed that only the last party required the application thread, but alas this was not the case.

group.getChildren () .add also requires that the thread of the application. Why?

node.setLayoutX () also requires that the thread of the application. Why?

It is a new set of nodes that are not visible and groups yet, so why can't do this in a background thread?

The reasons of principle (I think) that JavaFX is mainly a single toolbox threaded are described in:

https://weblogs.Java.net/blog/2004/10/19/multithreaded-toolkits-failed-dream

That said, if you manipulate objects that are not part of an active scene, then it should work.  The dream that failed has what to do with the components who participate actively in the molten, interactive GUI.  If you're interacting with only the components out of the screen, then it (should be) without issue.

Please, create and post an example minimum, executable that replicates the question.

(Please ensure that the example is minimal and executable).

In addition, what is the cause as your application "takes some time to update the scene?  Computers are today quite incredibly fast.  Of course, there are valid reasons for some things take time, I wonder what these are in your case.  What is the time?  If your executable example can include something reasonably representative of what you're done which shows something that will take "some time", would be great.

What you have described so far, I feel that, even if there is no problems with threads, your proposed approach would not fix your performance problem.

Tags: Java

Similar Questions

  • MenuItems run() method that is called from the thread eventdispatching?

    Hello

    is it? I know that MenuItem itself extends thread, but I wonder why this method is called run() and finally and above all it would'nt be worse if this method would be called from a Thread.

    THX

    In fact the menu items are run on the thread of the event. You can see this by creating a menu item long-term. The menu will not close and will not refresh the screen.

  • getLocation() method cannot be called from event thread

    Hello

    I use a thread that runs an executable object, which gets gps location. This thread is called in the constructor of the form. The first time, it works fine, but then I get the error getLocation.

    class GetGPSThread extends Thread
    {
    GPSRunnable _gpsObject;
         
    GetGPSThread()
    {
    _gpsObject = new GPSRunnable();
    }
         
    public void run()
    {
    _gpsObject.run ();
          
    While (! _gpsObject.isFinished ())
    {
    try {}
    Sleep (200);
    } catch (InterruptedException e) {}
    Generative TODO catch block
    e.printStackTrace ();
    }
    }
          
    Renew the screen
    If (_gpsObject.getLatitude ()! = 0 & _gpsObject.getLongitude ()! = 0)
    {
    UiApplication.getUiApplication () .invokeLater (new Runnable()
    {
    public void run()
    {
    loadScreen (_gpsObject.getLatitude (), _gpsObject.getLongitude ());
    }
    });
    }
    on the other
    {
    UiApplication.getUiApplication () .invokeLater (new Runnable()
    {
    public void run()
    {
    Dialog.Alert ("your position not found");
    }
    });
            
    }
         
    }
         
    }

    "This thread is called in the constructor of the screen".

    We see this code in your constructor?.

    I guess you really want to say this thread is 'start '.  Don't forget that

    . Run()

    does not run a Thread, it executes the run() method in the Thread.  To start a separate Thread, you must use

    . Shart().

  • Why almost all of the site have to Re-enter an e-mail address in a 2nd email registration textbox?

    Why almost all of the site have to Re-enter an e-mail address in a 2nd email registration textbox?

    Saturday, October 13, 2012 03:37:18 + 0000, stuckfree wrote:

    Why almost all of the site have to Re-enter an e-mail address in a 2nd email registration textbox?

    They want to make sure you typed it correctly. If the two are the
    Ditto, it is probably correct, but if they are different, you probably
    made a typo.

    Ken Blake, Microsoft MVP

  • Need for a method to be called when the pop-up screen

    Hello

    I have a requirement in my application. I have a screen from which I'm moving to screen B. When I Pop the screen B, I need a method that must be called in the screen has. Looks same as onActivityResult() in Android.

    I am currently using onExpose(). But this method is called for all in the screen has. In the menu click or button also. Is there another way to do this?

    Help, please...

    You have two options I can think immediately, which do not have to change anything in screen B.

    (1) use pushModal when you call B screen.  The statement immediately after the pushModal will be executed as soon as B screen is popped.  In general, I try to avoid the modal screens, but in this case, it's probably what I would do.

    (2) set an indicator immediately before you tap screen B.  Test the flag in onExposed().  If the flag is not set, then the onExposed was called for another reason and you can ignore it.  If the flag is set, then turn him off and process you want, knowing that the screen that has been exposed as screen B jumped.

    Either should work for you.

  • ERROR, called from the thread NON-INTERFACE QThread

    I am trying to load an image using QtConcurrent:map at the same time and I received this error.

    WARNING: ApplicationPrivate::context: ERROR called NON-INTERFACE QThread thread (0xf9ff68, name = "thread (pooled)" ")
    Fatal: ApplicationPrivate::context: method called from the UI thread

    I simplified the code as follows:

    imagescaler::queuescaling{
    ..    mimageScaling = new QFutureWatcher(this);
    mimageScaling->setFuture(QtConcurrent::mapped(mImageList, scaledImage));
    ..
    }
    
    Image scaledImage(QString file_name) {
       QImage qImage;
       bb::ImageData imageData(bb::PixelFormat::RGBA_Premultiplied, qImage.width(),
      qImage.height());  // causes error
      return imageData;
    }
    

    Anyone know what the problem is or how to work around?

    Thanks for point out the bb:ImageData.  Never noticed the incompatibility.  Image converts ImageData to initialization, so it does not create an error.  However, if I return an ImageData rather than the Image it does not crash.  I then simply convert ImageData of Image in the UI thread and it works very well.

    I'm curious to know why I can return a blank image and I can return an imageData, but I can't go back an Image that's been converted from ImageData.  Do not understand what can or cannot be done outside the UI thread.

  • Why I can't mount images in InDesign from the 'images' as I did with "iPhoto" before?

    Why I can't mount images in InDesign from the 'images' as I did from "iPhoto" before?

    Browser multimedia lla only will show you photos from your photo library, if the library is your system library.  Check in Photos preferences > general, if 'use as a Photo library system' is UO greyedcrossed, as it should be.

    and the application must be fully compatible with El Capitan, or it can only show the iPhoto and Aperture libraries.  You may need to update your copy of inDesign. I don't know, if there is a newer version.

  • Unexpected calls from the Germany

    Yesterday, I started to receive calls from the Germany. People say that they missed call on their phone, that's why they are callimg me back. I checked the call history and I did not call these numbers. Is it possible that there is a double reality of my number online?

    Hello

    Sorry, you encounter this problem,

    Please file here:

    Contact customer service

    TIME ZONE - US EAST. LOCATION - PHILADELPHIA, PA, USA.

    I recommend that you always run the latest version of Skype: Windows & Mac

    If my advice helped to solve your problem, please mark it as a solution to help others.
    Please note that I usually do not respond to unsolicited private Messages. Thank you.

  • HP officejet j4580 all-in-one will not print from the internet.

    My officejet j4580 all-in-one printer does not print all that I try to print from the internet, or in microsoft word.  I tried to reinstall, but it gets stuck at 94%, and it took almost 3 hours to get to this point.  What can I do?  My operating system is vista from microsoft.

    Hello

    Here are a couple of things to try.  I would first start by download and run the Diagnostic Print utility.  IF this isn't clear, then try the document on the internet printing problems.

    Print Diagnostic Utility

    Problems printing from the Internet

    See if one of these help.

  • Strange call from the India, claiming that they had been notified that there was an error in my computer?

    Just got a call from the India, claiming that they had been notified that there was an error in my computer? Is this normal? About an hour earlier, I have defraged my computer?

    Hello

    It's a SCAM

    they want or money on your part for programs without value or make an identity theft on you to get even more money and get your internet banking passwords and credit card information, you get allows you to download the software to 'fix' or 'test' for your computer

    read this:

    http://www.Microsoft.com/security/online-privacy/msName.aspx

    Microsoft has none of the unsolicited telephone calls to help you fix your computer

    In this type of scam cybercriminals are calling you and claim to be of Support technique Microsoft. They offer help with your computer problems. Once scammers have earned your trust, they try to steal and damage your computer with malicious software, including viruses and spyware.

    Although the law enforcement can trace phone numbers, often authors use pay telephones, disposable cell phones or stolen cellular phone numbers. Better avoid fooling themselves rather than try to repair the damage afterwards.

    Treat all unsolicited sceptically telephone calls. Don't provide personal information.

    If you receive an unsolicited call from someone who claims to be from Technical Support Microsoft, hang up. We do not have such calls.

    If you think you might be a victim of fraud, you can report it. For more information, see: what to do if you think you have been scammed.

  • BlackBerry smartphones can not make calls from the home page or the phone book.

    I've had my curve for several months now and the other day, that my most young got a hold of it... I don't know how they do it, but my children can do things with my phone and computers that I did not know they could do... In any case I tried to access my voicemail by organizing the 1 on the homepage and it took me to instead call log, so I tried to make a call from the phone book by selecting the name pressing on do it call button and no as soon as I actually had to go into the call log and manually type the number.

    My question is... What did do?  It is very aggravating and I would ask him, but he is two... I know he did not drop it or I would take it to a service provider.  All of the suggestions.

    Thank you

    If you go in your call log icon or by phone, click your menu button and go to Options. Then, go to the General Options. See if your the home screen dial is set to Yes.

    Also try to reset your device by removing the battery for 1 minute and replacig it to leave the unit restarts. Try it later

  • Why people of Iran can not download or update the application?

    Why people of Iran can not download or update the application?

    What app?

  • When I press the tab button all my favorites in a show from the list-how to make that happen?

    When I press the tab key to open a new page, all my favorites in a show from the list-how to make that happen? It should be a correct white page or the home page?

    said CWEB

    When I press the tab key to open a new page, all my favorites in a show from the list-how to make that happen? It should be a correct white page or the home page?

    OK this question I figured it adds on the deletion settings

  • Hello someone can help me please? I received a call from the CTIC Tech and they gave me Anti Malver software. I would like to ask you about it?

    Hello

    can someone help me please? I received a call from the CTIC Tech and they offered me an Anti Malver software which I paid 179 euros. I would like to ask you about it?

    These phone calls, e-mails or popup messages will ALWAYS be a scam.

    You have been scammed.

    Based on your other posts, you aapear have called these criminals. You allow to access your computer?

    Note: Please stop rather create several threads with the same question, answer in one of the many other threads.

  • My browser is blocked for security reasons. Code error-QFR5000RT11C. My incoming connections in open State distance. Then I got the call from the United States 1 (866)986-3669, I picked up the phone, but they put the phone down. No matter what? Help, plea

    My browser is blocked for security reasons. Code error-QFR5000RT11C. My incoming connections in open State distance. Then I got the call from the United States 1 (866)986-3669, I picked up the phone, but they put the phone down. No matter what? Help, please.

    It's probably a SCAM.  Do not call these numbers.  Force Quit Safari and reopen it by holding down the SHIFT key.

    Ciao.

Maybe you are looking for