Running two methods at the same time

Hi, I need to run a bubble sort and an insertion sort at the same time.
How can I do this? Threads?

It doesn't work when I put in the algorithms though.
It works when I do this:
Bubble class:
          for(int x=0; x<20; x++){
                try {
                    Thread.sleep(0000001);
               } catch (InterruptedException e) {
                    return;
               System.out.println("yes");
          }Insertion class
          for(int x=0; x<20; x++){
                try {
                    Thread.sleep(0000001);
               } catch (InterruptedException e) {
                    return;
               System.out.println("no");
          }but when I try it on an algorithm it doesn't do anything
public void insercionDirecta(int [] a, int[] num){
          for ( int i = 1; i < a.length; i++ ){
             int aux = a;
     int aux2 = num[i]; //coordenadas y
     int j = i - 1;
     while ( j >= 0 && aux < a[j] ) {
     a[j + 1] = a[j];
     num[j+1] = num[j];//
     j--;
     a[j + 1] = aux;
     num[j+1] = aux2; //
     try {
                    Thread.sleep(60000);
                    } catch (InterruptedException e) {
                    return;
     System.out.println("1");
     }]/code]
I've tried different amount of milliseconds and it doesn't work....
my run() is like this
     public void run()
          int [] a = {5,2,4,3,1};
          int [] num = {1,2,3,4,5};
          insercionDirecta(a,num);
} any ideas?

Similar Messages

  • Can i run two widgets at the same time on the same page?

    Can i run two widgets at the same time on the same page?
    Hi
    I have created and published 4 free ibooks and i would to run two widgets
    - a countdown clock
    - a review test
    at the same time on the page. Can i do that?
    Thanks in advance
    Haris

    thanks for your answer. Yes indeed HTML widgets run only full screen (snif snif). I consider this as a "distinguishing treatment".
    One solution  i read !!!!! was to create through keynote a countdown clock, to export to quicktime move and to imported at iBA predefined widgets. of course this is not the solution i need.
    So, in order to have at the same widget and run together a count down clock and a preview test (20 questions)  i must
    1)"hack" the preview widget and insert a countdown clock
    2) create a preview test using iAD.....
    thanks again
    haris

  • Run two VIs at the same time

    Hello!
    I want to know how i can run two VIs at the same time.
    I mean that i want to run a second VI ( N.2) while another VI (N.1) is in
    execution without suspend it (N.1)
    If anyone has suggestions, please help me!
    Thank you very much.
    roby.

    If you say "run a vi", I assume that you have the VI open in LabVIEW, then press the run button. (Some of the earlier answers taks about programmatically calling VIs, which I don't think is the focus of your question)
    You can run as many VIs as you want at the same time. Simply press the run button of the second VI and they will both run.
    Of course you should ensure that they don't use the same resources (e.g. DAQ device, or listen on the same TCP port, etc.) In these cases, the second VI might fail. (Also if the second VI is a subVI of the first VI, you won't be able to run it seperately, because it will be already running.)
    LabVIEW Champion . Do more with less code and in less time .

  • Can i run two PIDs at the same time?

    Hi
    I want to control speed of the rotating shaft and force applied by the pneumatic cylinder using two different PIDs from the same program.
    I managed to get two PIDs to work separatly using PID control loop VI`s supplied with labview 6.1 (I got Kc, I and D right, so there is no overshoot). When I try to run both PIDs within my vi they don`t work. I again tried various gains and managed to get one PID to work but not the other. Then through trial and error I managed to get a second PID to work but I had to change refresh time of the FOR loop from 100msec to 1msec.
    Does anyone have experience with running two PIDs in the same program? Does the timing of the FOR loop influence PID contorller? Does equiring of other data while
    running PID has effect on the PID?
    I would really appreciate any comments/help. I am pretty thrustrated at this time
    Thanks

    I don't know whcih PID vi's you are using but I had similar problems. I
    solved it by going to the VI properties of the PID subvi, select category
    execution and make sure that reentrant execution is selected. Only then two
    instances of the PID vi can run without interfering each other.
    Martien
    solved by setting the execution mode
    "smartlander" wrote in message
    news:[email protected]..
    > Hi
    >
    > I want to control speed of the rotating shaft and force applied by the
    > pneumatic cylinder using two different PIDs from the same program.
    > I managed to get two PIDs to work separatly using PID control loop
    > VI`s supplied with labview 6.1 (I got Kc, I and D right, so there is
    > no overshoot). When I try to run
    both PIDs within my vi they don`t
    > work. I again tried various gains and managed to get one PID to work
    > but not the other. Then through trial and error I managed to get a
    > second PID to work but I had to change refresh time of the FOR loop
    > from 100msec to 1msec.
    > Does anyone have experience with running two PIDs in the same program?
    > Does the timing of the FOR loop influence PID contorller? Does
    > equiring of other data while running PID has effect on the PID?
    > I would really appreciate any comments/help. I am pretty thrustrated
    > at this time
    > Thanks

  • "Newbie" Unable to run two actions at the same time please help

    Hello
    I'm a newbie (2 weeks) on Labview, so I hope my problem will sound easy for some of you.
    I want to read a file and at the same time get the reading from my sensors (4 sensors).
    My program is working when I do each thing in a different program but when I add them the program only read the text file and stop reading the sensor signals...I attach the program file.
    The goal is with the text file to add an exact time for each sensor signal I record.
    Is there any other possibilities to include a time with the sensors signals recorded ? I need to do this to synchronize the sensors values with CAM program.
    Thanks
    /Xavier
    Ps I used a scan rate of 12000/s but I try 1000/s
    and the sensor acquisition is still not working
    Attachments:
    test3Rdif2802.vi ‏493 KB
    readfile.txt ‏195 KB
    sensoracquisition30s.txt ‏210 KB

    from a glance at your code, it appears that you have nested a loop to read your file, inside a loop to read your sensors. this means the nested loop to read your file must finish before the outside loop to read your sensors can run through another iteration. what you want to do is separate the two loops to run independently of each other (in parallel). use a global variable to know when to stop the loop (if they need to stop at the same time) and if you need to pass data between the loops use a queue (easiest) or you can also use globals with semaphores.

  • Run two vi at the same time

    I WANT TO HAVE A VI RUNNING (WHILE LOOP, COLLECTING DA DATA, OPERATING AN ACTIVE TEST, ETC.) AND WHILE THAT IS GOING ON, OPEN ANOTHER VI (FROM WITHIN THE MAIN PROGRAM) TO DO SOME SEPERATE FUNCTION (PRINT OUT A LOG REPORT, PREVIOUS TEST RESULTS, ETC.). BUT EVERY TIME I OPEN ANOTHER VI's WINDOW, THE MAIN PROGRAM WINDOW's WHILE LOOP STOPS LOOPING.
    I AM SURE IT IS JUST A SIMPLE SETTING, BUT SO FAR HAVE NOT BEEN ABLE TO FIND THE RIGHT SETTING OR AN EXAMPLE OF TWO VI LOOPING AT THE SAME TIME.
    THANK YOU FOR THE HELP.
    DOGFACE

    I HAVE ATTACHED A ZIPPED FILE CONTAINING TWO SAMPLE FILES (CARL1MAIN.VI AND CARL1SUB.VI) THAT SHOW WHAT I WAS TRYING TO DO. I HAVE BEEN USING TEST POINT AND HAVE RECENTLY SWITCHED OVER TO LABVIEW, SO I AM STILL LEARNING. I TOOK BOTH BASIC COURSES (AND SCHEDULING ADVANCED COURSES IN LABVIEW). BUT BECAUSE OF THE DIFFERENCES BETWEEN LABVIEW AND TEST POINT, I MIGHT BE STRUCTURING THIS WRONG.
    I AM OPEN TO ANY SUGGESTIONS.
    THANKS.
    Attachments:
    CARL1.zip ‏16 KB

  • Running two EXE at the same time

    I have two EXE.
    I cannot run both at the same time.
    What should I am doing wrong?

    Yes, these are two different applications with different names.
    I double-click on the first EXE and I see the start-up form. Good so far.
    I double-click on the second EXE and I don't see the start-up form. Instead the "icon" for the first EXE in the taskbar flashes.
    I am running Visual Basic Express 2010.
    Are these some settings for the compile that I should be using?
    Individually the two EXEs work fine. 

  • Run Multiple Methods at the same time

    Hey Everyone,
    So here is my dilemia. I have these three classes and two of them are subscribers to a middleware so when I call one of these classes to subscribe the code stops while the subscriber listens for the message. The problem is that the other class I have is the publisher and unless I want to run the publisher as a separate script I need to find a way to run it once the subscriber is listening. Some have suggested I use a callback but I am unfamiliar with how a callback would work. In Matlab when I use callbacks I still end up waiting for the subscriber to come back with a response so I am not sure this is the solution to my problem in Java.
    I have a main method in a main class which calls methods in each of three classes however once it subscribes to the first one on the list it stops and waits for the subscriber to finish working. Does anyone have any suggestions of how to allow the subscriber to continue to listen but still return back to the main method and allow me to run the next subscriber and so on? Thanks for your help!!

    You'll need some sort of multithreading. Whether you roll your own or there's some prepackaged tools out there you can use, I don't know, as I didn't understand your requriements very well.
    http://java.sun.com/docs/books/tutorial/essential/threads/

  • Is it possible to run two applications at the same time on ipad.

    Hi,
    I would like to know of it is possible to play media apps (movies or bbc iplayer programs) while surfing the Internet with safari on ipad2. Even if I can't actually see the video while I'm surfing the net but can still hear it and can jump between the Internet and the movie without the movie stopping.
    Somehow I think the answer to this is no but then I also thought it wasn't possible to do print screen images with ipad until someone showed me how.
    Can anyone help?
    Thanks :)
    Locard

    Prior to iOS 6, it was possible to "multitask" with some media like playing audio from YouTube video while playing a game or surfing the web, but it changed in iOS 6.
    There are always a few surprises in major iOS releases, so who knows, it might work again in iOS 7. I never set my expectations for anything other than what Apple talks about publicly, but like I said, you never know.

  • Singletons running on two servers at the same time

    Hello,
              we faced one interesting situation with our application, running on clustered BEA Weblogic 9.2. We implemented some Singletons (ie. Singleton Service in a Weblogic cluster) and they are running fine. Most of the time.
              Common scenarios: cluster is started -> the singletons run on one server; the server is brought down -> the singletons are started on the second server.
              However, we had recently two situations where the Singletons started on both servers! Here they are:
              1) We use Database Migration Basis and we have a dedicated table for Weblogic to capture current state of the singletons. Due to the fact that database (Oracle RAC) was partially available one of the Managed Server could not get the lease and probably assumed that no singleton is running, therefore started the singletons locally.
              2) Network outage: we had several minutes where none of our servers could communicate between them (neither between SASU MS nor with the database). Consequence: each MS decided to start the singleton locally (after some time, which I assume is the waiting time). Once the network came back the servers could communicate again but the duplicate singletons are not deactivate, so they are running in parallel.
              Anyone experienced the same or similar issues? How to prevent the above? Is the Consensus Migration Basis a better choice? (I think yes for #1 but not for situation #2).
              Any helpful answer is appreciated.
              Thank you, best regards,
              Remus.

    In general its not a good idea.  Running PSConfig will try to establish a lock on the configuration database.  Doing that from two servers at the same time may cause the update to fail.
    Paul Stork SharePoint Server MVP
    Principal Architect: Blue Chip Consulting Group
    Blog: http://dontpapanic.com/blog
    Twitter: Follow @pstork
    Please remember to mark your question as "answered" if this solves your problem.

  • My MacBook is almost two years old and has started running really slow. It gets bogged down when it is running different programs at the same time, like Safari and Pages. It didn't react this way until recently. Any advice would be very welcome.

    My MacBook is almost two years old and has started running really slow. It gets bogged down when it is running different programs at the same time, like Safari and Pages. It didn't react this way until recently. Any advice would be very welcome.

    Launch Disk Utility and select the icon of the internal drive (the drive itself, not the volume icons below it.) Is the SMART status "Verified?" If not, replace the drive immediately. If the status is "Verified," the drive may still be failing. Back up all data, if you haven't already done so. Reinstall Mac OS X, then run Software Update. Test with all wired peripherals disconnected. If it's still slow, you have a hardware problem.
    Mac OS X 10.6 Help: Reinstalling Mac OS X

  • Running pse on two computers at the same time

    I have installed pse 12 from the same disk on 2 computers.  One computer runs pse 12 and the other doesn't.  Is it because I'm only allowed to run the program on one computer at a time?

    Do you run pse 12 aat the same time on 2 macnines?
    No.  I must admit I don't have PSE12 yet.  I suggest wait for Barbara, Kelly or others who have PSE12 because they are in a better position to answer this than I am.
    Sorry for the confusion.
    BARBARA OVER TO YOU.

  • How can I start two Vi at the same time?

     I have two Vi's, each of these Vi has a stop button. I want to start these two Vis at the same time. I also want to be able to stop the two Vis at the same time. What should I do? Thanks.

    One way to start them is with an Invoke Node and the Run method. You can then stop them with the Set Control Value [Variant] method. When you use the Set Control Value [Variant], you just have to specify the name of the front panel control that stops the while loop. Older versions of LabVIEW only had the Set Control Value method in which you had to use the flatten to string function to pass the Type Descriptor and Flattened Data.
    Message Edited by Dennis Knutson on 03-20-200609:35 AM
    Attachments:
    Run Method.JPG ‏44 KB

  • Two profile two thunderbird at the same time with same user account

    Dear,
    I would use two Thunderbird at the same time for two different profiles with the same user accounts.
    I using linux OS.
    I was thinking of using:
    # thunderbird -P profile1 &
    # thunderbird -P profile2 &
    But when launching the second command nothing happens.
    Only brings in the foreground thundirbird already started.
    If possible use this configuration now or in the nex future?

    As a rule thunderbird only runs one instance of a profile.
    However, there are a couple of options you could try.
    You could use an addon to esily switch profiles:
    * https://addons.mozilla.org/en-US/thunderbird/addon/profileswitcher/
    there is more help here:
    * http://kb.mozillazine.org/Run_multiple_copies_of_Thunderbird_at_the_same_time
    It does say: 'Multiple instances is intended for debugging, so use it at your own risk'.
    One method would be to use: Start > Run
    "C:\Program Files\Mozilla Thunderbird\thunderbird.exe" -no-remote -P profilename
    there is a space before '-no'
    and also before '-P'
    followed by a space and the profile name
    You could create a shortcut/icon to run each separate profile.

  • Using the same object in two actors at the same time

    Hello,
    I'm in doubt.  In my application, for example i have three Hardware classes - Database, DAQ1, DAQ2.
    Database class has one main method (except initialization methods) - Log Measure.
    DAQ1 class also has one method - Get Voltage, and DAQ2 class has one method - Get Current.
    Then i define two HAL (Hardware Abstraction Layer) classes - Measurement1 and Measurement2.
    Each of those classes have two main methods, respectively - Measure Voltage and Measure Curent. They also have some initilziation methods.
    In code, i create three objects of Hardware classes - Database, DAQ1 and DAQ2 and initiaze it. For example in Database private cluster i have DB RefNum, in DAQ1&2 i have device addresses etc.
    Next I initialzie Measurement1 with two hardware objects - Database and DAQ1, and in the same way - Measurement2 with Database, and DAQ2 objects.
    What Measure Voltage and Measure Curent (methods of Measurement1 and Measurement1 objects) do?
    Measure Voltage method call DAQ1::Get Voltage method, then Database::Log Measure.
    Similarly, Measure Current method call DAQ2::Get Voltage method, then Database::Log Measure.
    Till now it's clear i think. It should work properly.
    But now i incorporate Actor Framework, and define Measurement1 and Measurement2 as an actors.
    Now i can run Measurement1 and Measurement2 at the same time, simultaneously, but this two actors share one object - Database. So my question - what is when actors want to use Database::Log measure method at the same time and this method is time cosuming (for example large pack of data).
    Is one actor waits for second to stop executing this method of one shared object? I think yes because reentrancy setting (http://zone.ni.com/reference/en-XX/help/371361J-01/lvconcepts/reentrancy/)
    But what, for example if i share one Hardware object of device (ADC converter) beetwen two HAL classes (Measurement1 and Measurement2). This Hardware object has two methods, for ex. Get Voltage At channel 1, and Get Voltage At Channel 2. Both of this methods cannot by call at the same time, because in physical device i can measure only at one channel in the same time.
    Let the Get Voltage At channel X meausere take 10 seconds. Now i have huge chance, that Measurement 1 actor call Get Voltage At channel 1 method, and Measurement 2 wants to call Get Voltage At channel 2, when Get Voltage At channel 1 is in process. How to inform actor to wait till second actor release device resources?
    Regards,
    Kacper

    Dear Kacper,
    the way I understood, there are two separate questions in this post, namely:
    I'm using a shared resource in multiple actors, and the code accessing the resource can take quite some time to execute. How can can I ensure this does not mess up the timing of one or all accessors?
    I'm using a shared resource in multiple actors, and the code accessing the resource can generate errors if I try to access it from multiple places. How can I ensure synchronization between all accessors?
    As for the first question, the optimal solution to separate the resource prone to timing issues in a different thread/actor. Put anything that is not strictly timed (file access, network comunication) in a separate loop. For each actor, you will get queue references to communicate with, so instead of logging the measurements in the actors where they are made, just queue them up for a different loop to process.
    For the second part, the same logic still applies. Ideally, every singular resource should be handled by its own thread and nowhere else, so if anything else needs data from/to said resource, it can send a request to the dedicated thread or actor.
    If, for some reason, this is not sufficient, you have to handle synchronization in some other way. There are a lot of techniques here, for example:
    Create a named semaphore or lock as a part of the class. Have class functions use the semaphore before accessing the resource.
    Use actor messages. Have a "resource in use" or "resource released" messages sent to all users whenever obtaining or releasing said resource.
    Have a separate actor handle all resources, awarding them to threads needing them. This method also allows setting priorities between requests.
    These are just a few examples, there are many other options.
    Please let me know if this was helpful. 
    Kind regards:
    Andrew Valko
    National Instruments Hungary

Maybe you are looking for

  • Abap Report Performance

    One of our abap report is extremely slow, this report is used by all branches of our company and we are facing serious performance problem in this report. I have analyzed the problem and noted following things. 1) The report used "BSIS" table for a q

  • Fax machine issue Cisco call manager

    Hi All Im having issue trying to get a fax machine to talk to a server but im having issues and I need to find out where the Fax is configured on GUI in the Callmanager. Please could some one help. Thanks

  • Document form events

    Scenario : I open Order form I write the name of the customer in the customer name textbox. I click TAB button to find the customer. I need now to catch the event, what is it ? FORM LOAD ? FORM ACTIVATE ? Giuseppe

  • Entity Dimension - Company Code + Profit Center

    Dear experts, I'm in a BPC project in NW, the project has two fronts, planning and consolidation, in specific I am with the initial concern of how to organize the dimensions, and is used by both sides. Explaining the situation, we will do the plannin

  • Select Modify Border always feathers

    Hi All, Apologies if this has already been discussed somewhere previously, but I'm getting very frustrated that I can't seem to easily accomplish what should be a very simple task: I am using CTRL+A to "Select All" and then trying to contract the sel