Multi-threaded in JavaFX game loop

I am trying to understand works threading model of JavaFX, to determine the best way to write my game loops. This moment, my approach is this:

EventHandler < ActionEvent > gameUpdate = event->

{

update of the world based on a timestep (see below) 33.3ms

};

gameLoop = new chronology (new KeyFrame (Duration.millis (33.3), gameUpdate));

gameLoop.setCycleCount (Animation.INDEFINITE);

My understanding is that:

  1. This should result in the game loop to run at around 30 FPS (the target frame rate), assuming that the gameUpdate does no more than 33.3ms.
  2. The changes I've made in the course of the gameUpdate causes a trigger pulse.
  3. This impulse is an event on the JavaFX application thread. Such an impulse ends a synchronization between the JavaFX application thread and a thread of rendering of the Prism.
  4. The gameUpdate runs on the same thread of request, so the pulse will run after the gameUpdate.
    By that I mean that the gameUpdate will never be interrupted by a pulse, which could cause the world to be returned in an intermediate state.
  5. Event handlers also run on the same thread, so I need not worry you synchronize them.
  6. Changes to the live nodes by event handlers will cause an additional impetus to be triggered.

My questions are:

  1. I understand that correctly?
  2. When working with animations (for example. RotateTransition), this animation triggers its own pulses, actually being run to a framerate higher than the loop game?

Thank you!

> I tried AnimationTimer also, but that does not seem suited to the steps of fixed time...: 'the AnimationTimer class to create a timer, which is called in each frame, while it is active. This seems to indicate that the timer is called on each pulse...

Yes, this is how the timer works, it is called on each pulse.  Generally, the pulse occurs regularly, 60 times per second.  However, if your code (or internal JavaFX code), a lot of work to do on a given pulse, for example you added 100 000 rectangles at the scene, then the impulse will have more than 1/60th of a second.  The AnimationTimer provides a hook you can hang off of to execute logic when occurs a pulse, but how many times it is called depends on the current frames per second (FPS), which the application is running under (which can vary from an intensive application graphic or logic).

--------

> I understand that well?

I think that understanding is generally correct, except for the statement about additional impulses.

> The changes that I made during the gameUpdate causes a trigger pulse... Changes to the live nodes by event handlers will cause an additional impetus to be triggered.

This is not really correct.   Pulse will always occur 60 times per second (or as soon as possible if the FPS is less than 60 FPS).  Nothing in the application causes an additional impetus.  However, if the application scene is static and don't change not, then pulse runs very quickly because he has little work to do.  JavaFX has mechanism of sale under construction node.  Only Sales (or modified) nodes are displayed on each pulse.  Between pulses, JavaFX will merge all the changes at the scene to determine all the nodes for a given impulse Sales and just make these Sales nodes.

For example, suppose that your chronology of animation for the game loop is set to trigger 30 times per second, then you could make a scene update on each pulse even.  If a scene update event handler is triggered on a strange impulse, an additional rendering will be on the pulse of odd to manage the sites updated.  If the same event handler is triggered on a same pulse, no additional rendering is required if the game loop is also updating the same nodes (because the nodes are already filthy and dirty nodes are only displayed once per pulse).

--------

If you want a very reliable timer which is called like clockwork and is not the potential system hazards pulse JavaFX, then you can use a standard Java Timer, but in doing so, you leave the nature single-threaded protected JavaFX environment when you run the code in the timer, so the Timer code can not update to the live scene graph nodes.  If the timer changes the State of the game which is shared by the event handlers and other reminders that run on the JavaFX UI thread, you will require thread and data synchronization mechanisms, which could get complicated quickly.

--------

I think that on the whole, the recommendation would be to run your loop to 60 frames per second instead of 30 frames per second (how you can as well use an AnimationTimer), if you want the best perceived sharpness (in the case otherwise, you find yourself with questions stuttering as such as Nvidia g-sync technology is built to correct, but g-sync as the technology is not widespread).

You can look at the code sample case brick (from Java Oracle 8 samples), because there were some changes to increase the fine (I think the code passed explicitly to a schedule that you set in your question to use the AnimationTimer, but check).

The eppleton game engine also uses the approach of AnimationTimer because it is the game loop.

-------

> When working with animations (for example. RotateTransition), this animation triggers its own pulses, actually being run to a framerate higher than the loop game?

Transition animations will be returned to each impulse, they trigger not their own pulse.  The animation can also trigger code to use (on the animation of JavaFX thread) when the time for a keyframe.

-------

I think that the way of thinking of time and transformation in JavaFX is that it is not continuous, but rather composed of discrete locations in which work can be done, if the slots correspond to each pulse and get up to 60 times per second.

Tags: Java

Similar Questions

  • Porting an application multi-threaded for Adobe Air.

    Someone at - it never been faced with this task?

    The application in question has a thread about 10 in addition to the main user interface thread.

    Each thread is blocking ops in long-distance communication, GPS, HTTP, manipulation of the filesystem, processing of data of general application, SQL execution, etc.

    Very little of it is based on the direct interaction of the user.

    Is it possible to get something like this in Adobe Air?

    Or simply wait for Android/BB... which would be realistic player out right at about the time where that this port is complete.

    Support an implementation not threaded with threaded implementations could be a lot of work.  I would recommend waiting.

    AIR has a flash.utils.Timer class, or a simple setTimeout() call that uses only the timer below.  The question is not "burden" on the UI thread, depending on CPU load... work has to be done one way or the other.  The issue is latency, in terms of how long it takes the application to respond to user events, or how long to make the updates.  Do more that small pieces at a time in the main thread, you will feel your app slow and inconsistent, with irregular updates and (if you try) animations jerks.

    Thread safety is not a big deal, normally... it is a matter of concern for applications poorly structured in a multithreaded environment.  Properly structured multi-threaded applications will eventually look a lot like an AIR application, with respect to certain things (for example, GPS pilot or connections SQLite) communicating through mechanisms of threads (queues, events, etc.) with the main thread.

    Called async stuff basically back to the main thread.  What are the event listeners.  You might be better not think of it as a wire when even... it's not like your "main thread" in another application, perhaps, where you have full control.  This is the main thread in a framework of GUI like WxWidgets or QT or whatever... everything is done with events and you * must * return to the caller (the frame) as quickly as possible or you will have a user experience impact.  Basically, the entire application is a collection of event listeners, with no place where you can implement a "loop of interrogation" for example, as you might in a different environment.

    Rather than stuff on 'simple threaded environments', you should probably just search for "asynchronous programming" or "event-driven" stuff.  There not much more to it than that.

  • Urgent: continous recorders of NIDAQmx and other instruments with multi-threaded vc ++

    I'm working on a software with vc ++ to control several instruments including a NO-DAQmx6289. For example, the features of the software.

    1. communicate with data acquisition card (card data acquisition) and continuously acquire data from several channels at a frequency of 1 kHz.

    2. connect with function via port RS232 1 generator, sending triggered bursts to the real-time features generator change state Ultrasound (G_usstatus) variable.

    3. connect with optical switch via RS232 2 port, send signals to switch between the two input channels (0,1) and six output channels (2,3,4,5,6,7) to the specified user to sequence and time interval (default: 150 ms), real-time change the channel connection variable (G_optchannel).

    4. in real-time, record data and the corresponding ultrasound status and connection status of optical channel in a specified file use for later analysis.

    I use multiple threads to make data acquisition (1-wire), control of the function (2 wire) generator and optical switch (3 wire).  I also need save data acquisition of data and the corresponding ultrasound status and use the connection status of optical channel in a specified file for later analysis. I use the following codes to read data continuously.

    Sub DataCollectionWin::ConnectDAQ()
    {DAQmxErrChk (DAQmxCreateTask ("", & taskHandle));}
    DAQmxErrChk(DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
    DAQmxErrChk(DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0,Dev1/ai1,Dev1/ai2,Dev1/ai3,Dev1/ai4,Dev1/ai5,Dev1/ai16,Dev1/ai17,Dev1/ai18,Dev1/ai19,Dev1/ai20,Dev1/ai21,Dev1/ai6,Dev1/ai7,Dev1/ai22","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
    DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",1000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,60000));

    DAQmxErrChk (DAQmxRegisterEveryNSamplesEvent (taskHandle, DAQmx_Val_Acquired_Into_Buffer, 50, 0, EveryNCallback, NULL));
    DAQmxErrChk (DAQmxRegisterDoneEvent(taskHandle,0,DoneCallback,));

    DAQmxErrChk (DAQmxStartTask (taskHandle));

    Error:
    If (DAQmxFailed (error))
    {
    DAQmxGetExtendedErrorInfo (errBuff, 2048);
    MessageBox (errBuff);
    DAQmxStopTask (taskHandle);
    DAQmxClearTask (taskHandle);
    return;
    }

    }

    Int32 CVICALLBACK EveryNCallback(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void *callbackData)
    {
    char l_optstatus_s [1] l_optstatus_e [1];
    char l_usstatus_s [1] l_usstatus_e [1];

    /*********************************************/
    Reading DAQmx code
    /*********************************************/
    If (! m_bStopTracking)
    {
    l_usstatus_s [0] = g_usstatus [0];
    l_optstatus_s [0] = g_optstatus [0]; Switching State optical before reading the data of 50 * 15

    DAQmxErrChk (DAQmxReadAnalogF64(taskHandle,50,10.0,DAQmx_Val_GroupByScanNumber,data,50*15,&read,));

    SetEvent (hEvent);
    l_usstatus_e [0] = g_usstatus [0];
    l_optstatus_e [0] = g_optstatus [0]; Status of the ///optical at the end of the reading of the data of 50 * 15

    If (read > 0) / / / save data in an exl file specified by "datafile".
    {

    Indicator = 1;

    for (i = 0; i<>
    {(/ / fprintf(datafile,"%d\t",i);}
    fprintf(datafile,"%c\t",l_usstatus_s[0]);
    fprintf(datafile,"%c\t",l_usstatus_e[0]);
    fprintf(datafile,"%c\t",l_optstatus_s[0]);
    fprintf(datafile,"%c\t",l_optstatus_e[0]);
    fprintf(datafile,"%.2f\t",data[15*i]);
    fprintf(datafile,"%.2f\t",data[15*i+1]);
    fprintf(datafile,"%.2f\t",data[15*i+2]);
    fprintf(datafile,"%.2f\t",data[15*i+3]);
    fprintf(datafile,"%.2f\t",data[15*i+4]);
    fprintf(datafile,"%.2f\t",data[15*i+5]);
    fprintf(datafile,"%.2f\t",data[15*i+6]);
    fprintf(datafile,"%.2f\t",data[15*i+7]);
    fprintf(datafile,"%.2f\t",data[15*i+8]);
    fprintf(datafile,"%.2f\t",data[15*i+9]);
    fprintf(datafile,"%.2f\t",data[15*i+10]);
    fprintf(datafile,"%.2f\t",data[15*i+11]);
    fprintf(datafile,"%.2f\t",data[15*i+12]*5);
    fprintf(datafile,"%.2f\t",data[15*i+13]*5);
    fprintf(datafile,"%.2f\n",data[15*i+14]*5);
           
    }
      
    fflush (stdout);
      
    }
    }
    }

    Now the problem is the data acquired with daq card does not match the corresponding registered swtich optical status (G_optchannel, which specifies the light connecting channels). High readings expected certain status really appeared in any other situation.  It seems that there is a misalignment of the multi-thread data. Because the optical switching State passes to 150ms, so I put DAQmxRegisterEveryNSamplesEvent to be trigued each 50samples, which means 50ms with 1 kHz sampling to avoid missing the changes. I also check if there is any change of status during the DAQmxReadAnalogF64, by registering l_optstatus_s and l_optstatus_e, which are actually the same. I wonder if this is because the data are first registered in the buffer. When the software starts reading, at that time, optical swtich status no longer reflects the State when the data was recorded first. Is it possible to fix this?  Thank you very much!

    kGy,

    I'm glad to hear that you are progressing with your project.  Timestamp data are always a bit tricky, because the process of querying a counter on the CPU is done asynchronously with the acquisition of your DAQ hardware.  However, your equipment will ensure that the relative chronology between samples is consistent (in your case, the data will be sampled every 1 ms).  And since you have changed your program as you are now all samples acquired reading, you know that each sample follows the previous 1ms.  So, if I were to implement this I think that I take an initial horodotage when I started the task and to calculate the timestamp for all samples following this timestamp (timestamp SampleN = (*.001s + horodotage initial N) or timestamp SampleN = timestamp SampleN 1 +. 001 s).

    I would go to do that, rather than the timestamp of the end of the reading for the following reason.  As I mentioned previously, the reminder of your reading will run when the OS is planning.  Therefore, it is possible that it gets delayed or does not exactly in phase with the acquisition of hardware, and make adjustments to your code to handle this problem.  However, when you're timestamping there is another thing to pay attention to.  It's the fact that your hardware has a FIFO where sampled data can accumulate before getting transferred to the memory buffer that reading from (for example if the bus PCI were busy when the sample was acquired).  Now assume that the stars aligned against us and get the following:

    (1) the operating system is busy with other things, and our reminder read gets delayed a few ms.

    (2) at the same time, another device connects the PCI bus (or part of the data path between your device and the memory used for the buffer).

    (3) one or more samples is momentarily blocked in FIFO of the device.

    If you were to read data timestamp at the moment, your timestamp would reflect the data in the buffer as well as data that was flying in the FIFO of your device.  However, you can only read data in the buffer.  Thus, time stamp applied to data that you just read would be a millisecond or two later they should be.  Suppose that on the next read reminder, this condition has cleared up itself.  This timestamp taken here would be accurate, however, you will need to return some additional samples (those who were stuck in the FIFO last time).  If you backcalculation your timestamp at this stage, I think that the timestamp calculated for these ecaple timestamps calculated on the previous reading.  It wouldn't be ideal, nor would it reflect when the data has been actually sampled.

    One of the remaining challenges is how exactly the start of time stamp feature.  To do this, I would like to add a call to DAQmxTaskControl (taskHandle, DAQmx_Val_Task_Commit) before calling DAQmxStartTask.  This step will advance the State template DAQmx as far as possible without actually starting the task.  This will help to DAQmxStartTask as soon as possible.  Now, before the appellant beginning or immediately after, I would take my initial horodotage (perhaps timestamp before and after and take the average).  Then I would use this original time stamp and my sampling rate known to calculate timestamps for all the rest of my samples.

    That got a bit long, but I hope it has been helpful.

    Dan

  • Multi-threaded error handling method

    I have a multi-threaded application.  When an error occurs in one of the wires causing the failed system, all threads will raise an error and display an error dialog box.  I think on the withdrawal of the appeal to the error handler in the secondary threads and instead send the error for the main thread to the provision.  Is this a common model?  Is there a better way to do it?

    kc64 wrote:
    I have a multi-threaded application.  When an error occurs in one of the wires causing the failed system, all threads will raise an error and display an error dialog box.  I think on the withdrawal of the appeal to the error handler in the secondary threads and instead send the error for the main thread to the provision.  Which is a common model?  Is there a better way to do it?

    Not as common as it is MUST.

    We use a logger who passes all errors to a background process that connects to produce for examination later. This is the minimum. If a fatal errors then adjust us the design of the application respond accordingly when bad things happen.

  • LabVIEW built of DLL in an application multi-threaded C++, need help!

    I'm working on a software application which is developed mainly in C++. There is a component of this larger application, however, develop in LabVIEW (for several reasons that I dive in here). This LabVIEW code is therefore run in a C++ wrapper class that calls a built DLLS LabVIEW.

    All this was fine and dandy, until we decided to multi-threaded, our C++ application for an increase in performance. Accordingly, the LabVIEW DLL now is called from multiple threads simultaneously. While this works on a functional level, it seems to create a bottleneck.  All my tests, it is resource locking occurs, such that only one thread has access to the .dll at a time. If I do the .vi used to define the dll as a non-reentrant function prototype so it's what we see. For example, say we have 3 sons all calling the same .dll method call. Thread 1, 2, 3 and all call the .dll file in a few milliseconds of each other. Thread 1 has completed the call .dll after X milliseconds. Thread 2 has finished the .dll call after 2 X milliseconds, and wire 3 full after 3 x milliseconds.

    Now, changing the vi home and runs the same test, we see wire 1, 2, 3 and all end them the call of .dll in 3 x milliseconds. While the fact that they are now the same amount of time to complete you would lead to believe they are spend at the same time, the fact that it takes 3 x milliseconds as opposed to X milliseconds means that they are not.

    Has anyone ever dealt with these issues before? Is it possible to play with the "delivery system" for the vi will have an effect? What happens if .dll methods while remaining attached to the same .dll are called from different threads? Same behavior? Is it a lost cause? Is there any way to make the code in a DLL only built LabVIEW run in two different threads at the same? What I understand is easily achievable with a normal (non - built LV) .dll.

    Please, if anyone has any advice in this area, let me know!

    Much appreciated,
    Jesse Hurdus

    Hi jhurdus,

    I know that you are working with an engineer OR this question, but I wanted to post a reply to one of your last questions.

    When you use the function node library call in LabVIEW, there is the possibility to select 'Run in the user interface thread' or 'run in any thread '.  This option, according to the help file for LabVIEW (dialog box call library functions), allows the developer to pass thread library function node call from the (default) user interface thread to the thread that the VI is running.  Additional details of when you want to switch the thread of execution are in the help file.

    Kevin S.

    Technical sales engineer

    National Instruments

  • Question no doubt multi-threaded

    Greetings!

    Don't know what kind of problem I face, but still very interesting.

    I have a UiApplication who starts a thread to listen to incoming SMS and respond automatically. This same class implements PhoneListener as below:

    public class SMSSenderReceiver extends Thread implements PhoneListener {
    
        private static DatagramConnection _dc;
        private static int _callIdIncoming;
        private static int _callIdAnswered;
        public static String _phoneNumber;
    
        static {
        try {
            _dc = (DatagramConnection) Connector.open("sms://");
            } catch (IOException e) {
                System.out.println(e);
            }
        }
    
        public SMSSenderReceiver() {
            super();
            _callIdIncoming = -1;
            _callIdAnswered = -1;
            Phone.addPhoneListener(this);
        }
    
        public void run() {
            try {
                for (;;) {
                    Datagram d = _dc.newDatagram(_dc.getMaximumLength());
                    _dc.receive(d);
                    String address = d.getAddress();
                    if (address.startsWith("//")) {
                        address = address.substring(2);
                    }
                    String answer = getResponseByPhone(address);
                    if (answer != null) {
                        answer.getBytes();
                        Datagram returnpacket = _dc.newDatagram(_dc
                                .getMaximumLength());
                        returnpacket.setAddress(d.getAddress());
                        returnpacket.setData(answer.getBytes(), 0, answer.length());
                        _dc.send(returnpacket);
                    }
                }
            } catch (IOException ioe) {
                System.out.println(ioe);
                Phone.removePhoneListener(this);
            }
        }
    
        private static String getResponseByPhone(final String phone) {
            TextResponses tr = TextResponses.getInstance();
            MultiMap mm = tr.getResponses();
            Enumeration valuesEnum = mm.keys();
            while (valuesEnum.hasMoreElements()) {
                String element = valuesEnum.nextElement().toString();
                if (mm.containsValue(element, phone)) {
                    return element;
                } else {
                    continue;
                }
            }
            return null;
        }
    
        //  public void missedCallSMSSender(final String address) {
        //      try {
        //          if(_callIdAnswered != _callIdIncoming){
        //              //              if (address.startsWith("//")) {
        //              //                  address = address.substring(2);
        //              //              }
        //              String answer = this.getResponseByPhone(address);
        //              if (answer != null) {
        //                  answer.getBytes();
        //                  Datagram returnpacket = _dc.newDatagram(_dc
        //                          .getMaximumLength());
        //                  returnpacket.setAddress("//" + address);
        //                  returnpacket.setData(answer.getBytes(), 0, answer
        //                          .length());
        //                  _dc.send(returnpacket);
        //              }
        //              _callIdAnswered = _callIdIncoming = -1;
        //              //_phoneCallsHash.remove("" + _callIdIncoming);
        //          }
        //      } catch (Exception e) {
        //          System.out.println(e);
        //      }
        //  }
    
        public void callIncoming(final int callId) {
            if(_callIdIncoming != callId){
                UiApplication.getUiApplication().invokeLater(new Runnable(){
                    public void run() {
                        _callIdIncoming = callId;
                        PhoneCall phoneCall = Phone.getCall( callId );
                        _phoneNumber = null;
                        try {
                            _phoneNumber = phoneCall.getDisplayPhoneNumber();
    
                            String tempNumber = null;
                            for(int i = _phoneNumber.length() -1 ;i >= 0; --i) {
                                if(Character.isDigit(_phoneNumber.charAt(i))){
                                    tempNumber = _phoneNumber.charAt(i) + ((tempNumber == null) ? "" : tempNumber) ;
                                }
                            }
                            _phoneNumber = tempNumber;
    
                            System.out.println("**bleep** Phone Number: " + _phoneNumber);
                        } catch(NullPointerException npe) {
                            _phoneNumber = "0";
                            System.out.println("NULL!!!!" + npe);
                        }
                    }
                });
            }
        }
    
        public void callAnswered(int callId) {
            _callIdAnswered = callId;
        }
    
        public void callDisconnected(int callId) {
            UiApplication.getUiApplication().invokeLater(new Runnable(){
                public void run() {
                    //System.out.println("**bleep** Phone Number: " + _phoneNumber);
                    //SMSSenderReceiver.this.missedCallSMSSender(_phoneNumber);
                    String address = _phoneNumber;
                    if(_callIdAnswered != _callIdIncoming){
                        //                  if (address.startsWith("//")) {
                        //                      address = address.substring(2);
                        //                  }
                        String answer = getResponseByPhone(address);
                        if (answer != null) {
                            answer.getBytes();
                            try {
                                Datagram returnpacket = _dc.newDatagram(_dc.getMaximumLength());
                                returnpacket.setAddress("//" + address);
                                returnpacket.setData(answer.getBytes(), 0, answer
                                        .length());
                                _dc.send(returnpacket);
                            } catch(Exception e) {
                                System.out.println(e);
                            }
                        }
                        _callIdAnswered = _callIdIncoming = -1;
                    }
                }
            });
        }
    ...
    

    The goal is to send an SMS for each missed call. Thus, on incomingCall while I get caller Id and phone number assign them static variables. If the call is answered I catch the call id also. Once the call is disconnected I just check the id of appeal responded and id entering in case they differ from each other, I got a call from miss and I send a SMS.

    The problem is once the callDisconneted is called, I don't have the value of _phoneNumber. On incomingCall I could see the number, but not after all. Why? Seems to be a fundamental basis on the multi-thread.

    Anyone know what is happening?

    Thanks in advance!

    --

    This question probably has to do with the fact that the listener to call is actually coming in your code on the phone application thread. Each application gets a copy separate from the static context. As a result, you won't see the same data when you access this variable in your own application process.

    You can probably here either: (a) send yourself a form of global event listener call, then pick up the event in your own process, or (b) use the runtime store to keep the value so that the two processes can * see * it.

  • Multi-threading

    I am looking to buy a new Mac Pro.  There are options that are inspired mainly by what applications you clocked.  He suggests that apps that don't take advantage of the multi-threading will perform better on processors with clock speeds higher while those who will benefit more from hearts.  Lightroom will perform better with more cores or a higher clock speed?

    Lightroom takes advantage of multiple threads so that saturates the CPU sometimes, but a lot of time, there are some other bottleneck on the system like i/o to disk or video memory so that thread or cpu optimization gains are dumb.

  • Multi threading issue.

    Hello
    I have worked on a project and would be grateful if I have a solution for this. The issue I'm facing is when two admin update the details of a "user" at the same time there are lines that are unique in the table. Here I use the framework KODO to remove and insert new values into the table when the administrator clicks the button Save. (here being complex update, delete, and insert is used).

    so when two admin clicks of the button simultaneously duplicate lines occur in the table.

    How can I solve this problem, I think using Sync is a bad option as he eats performance.
    Is there a way to correct this multi threading issue in java without locking or wielding resources (such as application performance does not diminish), since this part of my commonly used web application?

    The normal way to avoid this problem is to have a unique index on the table that prevents duplicate entries.

    I wouldn't delete the entry, only insert the entry if it does not exist and update it if it isn't.

    If you block on a unique key for the user/line (rather than the entire table) your overhead costs will be about 2 microseconds. It is very small for an interaction with the user-driven application. You could lock the whole table which may limit your request to about 100 updates per second, but would be much simpler to manage. Personally, if administrators perform more than 100 updates per second there is something wrong with your model.

    In short I just lock the entire table and optimize if it proves to be a problem.

  • Multi threading in flex concept?

    Hello

    I have an application with 4 quandrants. Each name separate webservice and based on the data in result I get, I build user interface elements dynamically. Unfortunately, I have to wait for each manager result in order to complete the construction of the user interface. Is it possible to run all 4 result together managers?

    Ex:

    I have 4 webservices: ws1, ws2, ws3 and ws4. I pass some parameters and invoke these services, complete creation:

    WS1. OperationName.Send ();

    WS2. OperationName.Send ();

    WS3. OperationName.Send ();

    WS4. OperationName.Send ();

    ws1ResultHandler(event:ResultEvent):void

    {

    }

    ws2ResultHandler(event:ResultEvent):void

    {

    }

    ws3ResultHandler(event:ResultEvent):void

    {

    }

    ws4ResultHandler(event:ResultEvent):void

    {

    }

    From the Web service operation which is managed to get the first data, this particular manager fires. Once all of the code in this handler is executed, she then gets in the next operation of webservice result handler.

    Is there a way to trigger all these handlers together and build together dynamically user interface elements at once?

    Appreciate your ideas on this.

    "Is there a way to trigger all these handlers together and build the UI together dynamically at THE SAME time?"

    Excuse my small edit, but the answer is 'no '. Flex is not multi-threaded.

    You can look at why it takes so long to build the user interface as a problem.

  • With Multi-Threading memory management

    Because the buffer of Photoshop Suite really does not want to be reminded of several threads (at least it is what I think I saw in the docs), what is the best strategy to manage memory dynamic allocation of in a plugin multi-threaded implementation?

    -Christmas

    Run the user interface in the main thread, allocate buffers in the main thread, the involved threads of shipping work.

    And Yes, the Plugin API is decidedly not thread-safe.  There are a lot of plumbing to clean before they can be thread-safe...

  • How to use multi-threaded file conversions?

    Hello

    I am able to convert .doc, .jpg file in pdf and in the margin

    I would like to thank all the people in this forum to help me get this thing done.

    In livecycle deployment guide I saw for multi threaded convertion I create at least 3 reviews with admin right.

    but my question is how I got these user programmatically to successfully accomplished this multithread convertion?

    I can't connect using these user of the admin user interface... Why?

    Thank you.

    Barun Baptist

    The user aren't LiveCycle users, users of the operating system. These users are used by LiveCycle when it launches the "native" applications used for conversions.  Users are necessary because many of the native applications (such as Microsoft Word) do not allow for multi-threading and thread saftey becomes a matter of concern.

    For example: I have three users of the system who are allowed to open Microsoft Office - Allen, Bob and Carl.  When I install LiveCycle I told on the three users during installation.  Later, I make a few requests to convert Word documents to PDF files.  If requests come simultaneously, one will be converted using the account of Allen, the second with Bob and the third with Carl.  A fourth request will be queued until one of the other conversions is finished.

    As a developer, you don't need to make the request on behalf of these users, which is controlled by LiveCycle.

  • my game loop


    My game loop works and I want someone to look at it to see if I can improve it AS3 style.
    What I do is load an image from a class and it dispatches an event when completed. When all images are loaded (which is 1 in this example) I then start the game loop which is just a trace.

    This way I could load many images and then start the my game loop

    This is a skeleton I can build upon.



    var noLoaded:int; noLoaded=0 var li:ClassImg2= new ClassImg2("ladybug.png",120,120); li.addEventListener("image_loaded",imageLoadedHandler); addChild(li); function imageLoadedHandler(e:Event){      stage.addEventListener(KeyboardEvent.KEY_DOWN,doSomething);   noLoaded+=1 } function doSomething(e:KeyboardEvent):void      {                      if (e.keyCode==37) //39 is right arrow           {                      trace("left pressed")           li.moveleft();                      }                      if (e.keyCode==39) //39 is right arrow           {                      trace("right pressed")           li.moveright();                      }      }       stage.addEventListener(Event.ENTER_FRAME, gameLoop); function gameLoop(event:Event)      {      if (noLoaded==1)           {           trace("all loaded");                }      }

    They are triggered regardless - it's the idea and the beauty of the events. Strictly speaking, because there is no multithreading in Flash - all events in treatment penetrates into the queue of the stack, but most of the time from the performance perspective, it is negligible. That said, your opinion on the control of collisions in the ENTER_FRAME event handler is the way to go.

  • game loop

    Can I move an image with a mouse and use a class to load the image.
    This works.

    T1) how can I put this code in a game loop in the file .fla that I need to move objects automatically? Can I use a timer or y at - it something better?

    Q2) how to report an event when the image of the ClassImg2 class has been loaded? I need to know this in the .fla file.

    below .fla file
    ////

    var li: ClassImg2 = new ClassImg2("ladybug.png",120,120);
    addChild (li);


    stage.addEventListener (KeyboardEvent.KEY_DOWN, doSomething);


    function doSomething(e:KeyboardEvent):void
    {

    arrow to the right of to //39 (e.keyCode == 37)
    {

    trace ("down left")
    Li.MoveLeft ();

    }

    arrow to the right of to //39 (e.keyCode == 39)
    {

    trace ("down right")
    Li.MoveRight ();

    }

    }

    "q1) how can I put this code in a game loop in the file .fla that I need to move objects automatically? Can I use a timer or y at - it something better? »

    It depends on the definition of "change". If you need a smooth animation - you will need an engine like TweenLite/TweenMax interpolation

    "q2) how to report an event when the image of the ClassImg2 class has been loaded. I need to know this in the .fla file. »

    Send the event to the class and listen to it on the timeline.

    Syntax for sending of the event:

    dispatchEvent (new Event ("eventTypeGoesHere"));

    Here's the documentation;

    http://www.Adobe.com/LiveDocs/Flash/9.0/ActionScriptLangRefV3/Flash/events/EventDispatcher .html#dispatchEvent%28%29

  • Clarification of the idiom of the neck/body in multi threaded applications

    Hello

    As some DBXML classes use the handle body language (idiom neck/body in some docs), could someone please clarify the consequences of that in a multi thread as a web container application?

    For the people of Java 100%, like me, it is known in the Java world as "programming to interfaces", or model of bridge; who is considered a good practice.

    Let's take an example. The XmlQueryContext class is not thread-safe, but it has a copy constructor. Imagine that your web application has a XmlQueryContext, that we never use in a query, but that prepares us can only be fully copied in further discussions. Is it safe to instantiate the various XmlQueryContexts again using the copy constructor, then, in various news feeds and use them at the same time?

    Thank you
    Koen

    PS Ce I'm wondering really here, is if someone could translate it please the following to talk about Java:

    A copy constructor is provided for this class. The class is implemented by using a language of the body handle. When a handle is copied both handles retain a reference to the same body.

    As a user of Java, you don't have to worry about how the C++ copy constructors behave. In the Java API if there is a copy constructor for the object, then the copy constructor copies all the data of the original object in a new object (XmlContainer is the only exception to this rule, generally do not use this constructor to copy at all). So basically, what you intend to do will work.

    Lauren Foutz

  • Multi-threaded custom device

    Is it possible to create a custom multithreaded device?  I want to create a client-server architecture, somewhat like the http://zone.ni.com/devzone/cda/tut/p/id/3098 example in a custom device.  The only difference would be that I would like to make the series of read/write in the high priority task.

    Thanks for the help!

    -Ryan

    Hi Ryan,

    This should be possible if you use a custom asynchronous device. The curls will then run in their own thread and do not affect the execution of the primary control loop. Make sure that there is enough time sleeping in your loop of high priority. Note, however, that put communication series in the loop of high priority will negatively affect your determinism.

    For more information on the Veristand engine and the custom device types you can choose one, please see the following:

    Understand the VeriStand engine

    Creation of custom devices

Maybe you are looking for

  • Maximum number of photos in Photos.app

    Is there a limitation?

  • Kernel Panic #2 and another batch of bad RAM?

    OKAY this is getting annoying. A few days ago, I posted about a previous kernel panic and if it linked to the bad RAM. My question has been answered by Illaass and Grant Bennet-Alder, the culprit in my kernel panic was bad RAM as Illaass noted The ex

  • Libretto U100 memory upgrade (2 GB, part II)

    I tried to respond to the http://forums.computers.toshiba-europe.com/forums/thread.jspa?threadID=39592&tstart=0 thread, but it is blocked? Srange. I had a glance my U100 Hardware information and there is certainly 1 x 1 GB memory available, so no mem

  • Satellite A100 (PSAA9): Win7 + setting screen brightness problem

    Hello I installed Windows 7 64 bit on my toshiba A100 (psaa9) machine and I cannot change the screen brightness more. It's always a maximum brightness. FN key doesn't work, and neigther Control Panel I can change the nvidia manually through the brigh

  • P6 - 2317c: BIOS problem

    I finally had the time to update the BIOS yesterday (I don't have a wish), and now I get the "6 beep" Choral when I start, but it takes me to the desktop.  When I try to reboot to get into the BIOS I get 6 beeps and a black screen. Have a feeling it