How do I make a program wait for a set amount of time?

Basically, I want there to be some amount of lag after a repaint, so how do I do that? I want it to wait a fifth of a second, basically. Is there a quick way to do this?
By the way, the program is not running on a timer, so I can't just have the timer stop.

didn't see that:
you need to use a thread
public class Something implements Runnable
Thread t;
public Something()
t = new Thread(this);
t.start();
public void run()
while(true)
//your stuff goes here
try
t.sleep(200);
} catch(InterruptedException exc) { ; }

Similar Messages

  • How do I make my program wait for tasks to execute

    I want to write a few java classes to do things for me, namely:
    1) Create a directory on a local machine which is named to the current date - that I can do with Calendar and String
    2) Download the latest committed code from SVN - I suppose I will have to use a process to call SVN from command line. Does Java have a local process caller? I'm familiar with Qt's QProcess, but I'd like to do this with Java.
    3) email confirmation that the tasks have executed - I can use javax.mail for that.
    If anyone has comments on 2, I'd like to know, please. My greatest concern is how to make sure that steps 1-3 execute sequentially. How do I get that right?

    System.exec(...)
    ProcessBuilderAlso read [When Runtime.exec() wont|http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html]
    It's equally applicable to processes launched by ProcessBuilder.
    db

  • Continuing a loop for a set amount of time

    Hi,
    I'm am trying to alter a previously written program have run into a problem.
    The program is set up so that when the input exceeds a set level an output voltage to a buzzer is created; the buzzer continues as long as there is an input.  What I need it to do is to continue this output for a set amount of time.
    I've been searching the forum and found this straight forward solution from adamsjr.
    "The easiest way to do this is to use a two Tick Count functions. The first
    one is outside of a While loop, the second one is inside of the While loop.
    Wire the first one through a tunnel into the While loop, add on the appropriate
    ms (5*1000), wire the sum to one input of a compare function. Wire the
    other input of the compare function to the second Tick Count function. Exit
    the loop when the compare shows the second Tick count value is greater than
    the summed value."
    I've got placed the output subVI into a while loop and followed the above directions and this doesn't seem to work. I'm wondering if I would also have to include the input subVI into the loop or is there another possible solution
    Thanks ahead of time,
    Kristen

    Hi Kristen,
    You have the compare function implemented incorrectly.  You need to make sure that the first terminal of the "Greater than or equal" function connected to the output of the sum, and the second terminal to the tick count in the while loop.  The first terminal corresponds to x parameter and the second terminal is for the y parameter.  So if x is greater than or equal to y, then the loop will need to exit.
    You can see how long a subVI is taking if you put a flat sequence structure within your subVI around the entire subVI code.  The first frame would only have a tick count going into an indicator, the middle frame your normal code, and then the final frame would contain another tick count wired into another indicator.  Then you can subtract the second indicator value from the first and get hold long it took to execute the middle (core) of your code for that subVI.
    I highly suggest using the highlight execution and probes and other debugging techniques such as breakpoints to diagnose where the data is being held up.

  • For Photoshop CC download do I have to pay the £8odd a month forever or for a set amount of time?

    I want to know whether there's a set price to the deal or will I be paying £8odd forever?
    I'd rather buy the full application, then and there, if that is the case. Save Money.
    Is there a set price? Or are you paying it if off monthly for a set amount of time?
    Can't find answers anywhere.
    Thanks In Advance!
    J

    You pay for your Cloud membership as long as you want to use the software.
    When you stop paying the software stops working. You never own the software. There is no set time when you finally pay it off - because it's a subscription model, not a rent-to-own model.
    If you want a pay once, own forever deal then you may be better off getting the superseded CS6
    Creative Suite 6

  • How to generate a continuous sine wave for a given amount of time

    I am trying to output a continuous sine wave for a speaker, but I am having difficulty making it continuous rather than looping the signal for a given amount of time, which causes discontinuities. There is a VI in the Labview examples titles Continous Generation, but it produces a square wave. Is there a way to adapt this VI such that the amplitude and frequency can be used as inputs to create a sine wave?

    I found a VI that ships with labview(7.0)called continuous sound output. the output of this is a sine wave or you can change it to whatever you want.
    Sorry cannot help more
    Joe
    Joe.
    "NOTHING IS EVER EASY"

  • How do I make a movie wait for a FLV cuepoint

    I'm trying to synch a "talking head" FLV with some graphics,
    so I simply want to get my movie to wait for a cuepoint to begin
    playing again. I'm making it Flash 7 compatible, so I'm using the
    older Media Display component.
    Is there a "stop" and "wait for cuepoint" that would work? If
    someone could give me the actionscript I should paste in the frame,
    it would be greatly appreciated, since I don't really know
    actionscript that well. Thanks.

    I'm sensing that you don't know much actionscript. If you
    want to do much that is really fun and cool you will need to learn
    some.
    Start with the help files. Everytime you use a new component
    or class go to the Actionscript Language Reference or the Component
    Dictionary. Don't try searching it will generally only confuse you
    more.
    This next bit is going to sound silly, but the differences
    are subtle and please take it in the manner it is offered.
    When you say you'd like to pause at a certain frame you mean
    a movieclip that you have, right?
    If you check all the information about the FLVs and the Media
    component you will find there is absolutely nothing that allows it
    to make a movieclip pause or play. But if you check the MovieClip
    class you will find there are the MovieClip.stop() and the
    MovieClip.play() methods. These are the only ways to get a
    movieclip to pause/stop and or play. There are no others.
    So you have most of the answer there in your second post. It
    is just worded a bit off.
    You need a movie to pause (for which you will use the
    MovieClip.stop() method) and when a cuepoint happens you will need
    to start the movie using MovieClip.play();
    If you check the MediaDisplay component directory there will
    be sample code for how to listen for a cuepoint. I'm still using
    Flash 7 so my help files are organized a bit differently, but what
    you are looking for is under Media.cuePoint.
    Notice the code at the bottom of the entry – READ the
    whole entry, even if you don't understand it all now, read it,
    outloud if it helps. You will need to have an instance of the
    playback component on the stage (in this example it is called
    myPlayback, but you could call it whatever you wanted, just make
    sure that both names are the same.
    I recommend trying this outside of your current project. Set
    up a simple new document, put an instance of the playback component
    on the stage, give it an instance name, assign an FLV to it, give
    it a cuepoint or two, and then add the listener code, just as it
    is. See how it works? Do you get the trace statements?
    Then you can develop it a little further. Add some named
    movieclip to your stage. Add a line myClip.stop(); Also notice that
    you can give your cuepoints names? Put a few in and call some start
    and some stop (or whatever you want.) Then instead of a trace in
    the cuepoint listener have something that says, "If the cuepoint is
    called start I should tell the movieclip to play and if the
    cuepoint is called stop I should tell the movieclip to stop/pause."
    I could easily write all this code out for you, but what
    would be the fun of that for you? Give it your best shot and post
    back as you accomplish things.

  • Setting up a Log File monitor to inactivity for a set amount of time

    I have set up a number of log file monitors to alert when certain conditions apply, such as the word "ERROR" or "exception".  Now I have a request to set up an alert if the log file has not changed for 20 minutes.  I have been
    searching and have not found any information on how or if this can be done.   Anyone???
    I am running Operations Manager 2012 SP1
    The log files are simple text files.

    Hi!
    You could create a timer reset monitor that reads the log file every 19 minutes for a wildcard pattern (everything matches) and configure the successful search to healthy. Further, you've to configure the timer reset to 20 minutes and configure the
    timer reset state to unhealthy (warning/critical).
    Keep in mind that SCOM reads from the last line from the previous run every time. If your file rotates (based on a schedule or size) SCOM will not read the lines until the latest line is reached. For more information refer to
    http://www.systemcenterrocks.com/2011/06/log-file-monitoring.html
    HTH, Patrick
    Please 'Propose/Mark as answer' if this post solved your problem. <br/> <br/> http://www.syliance.com | http://www.systemcenterrocks.com

  • Make a program wait

    Hi, I am new to Java, hence the forum, I was hoping someone could help, I was hoping to find a method or a way to make a program wait for the return key to be pressed, similar to the getch() function in C++ I have messed around a little with System.in.read() but I get an exception and I have no idea how to handle exceptions, any help would be greatly appreciated.
    Thanks in advance.
    UnclePunker

    you can simply do this by waiting in a while loop
    you have to import java.io.*;
    insert this into the main
    boolean goon = true;
    String answer = "";
    while(goon)
    //your code for number generation
    System.out.println("Result of"+num1+" + "+num2+" ?");
    BufferedReader in =  new BufferedReader(new InputStreamReader(System.in));
    try{
    answer = in.readLine();
    catch(Exception e){
    System.out.println("Error: "+e.toString());
    //the string answer contains the input from the console
    //if you want to compare it to an integer do this
    int numnber = 0;
    try{
    number = Interger.parseInt(answer);
    catch(Exception e){
    System.out.println("Error: "+e.toString());
    //code to compare the answer to the result

  • How do I make this program generate a new problem once the button is hit

    Here is the code... appreciate any help given
    How do I make this program generate a new set of problem when the "NEXT" button is clicked and continue until the END button is hit
    package javaapplication3;
    import java.awt.GridLayout;
    import java.awt.Window;
    import javax.swing.*;
    import java.awt.event.*;
    * @author Sylvester Saulabiu
    class Grid extends JFrame{
        final int score = 0;
        final int total = 0;
        Grid(){
            //Set Layout of Flashcard
            setLayout(new GridLayout(4, 4, 2 , 2));
            //Create Panels
            JPanel p2 = new JPanel();
            JPanel p3 = new JPanel();
            final JPanel p1 = new JPanel();
            //Create Radio buttons & group them
            ButtonGroup group = new ButtonGroup();
            final JRadioButton ADD = new JRadioButton("Addition");
            final JRadioButton SUB = new JRadioButton("Subtraction");
            final JRadioButton MUL = new JRadioButton("Multiplication");
            final JRadioButton DIV = new JRadioButton("Division");
            p2.add(ADD);
            p2.add(SUB);
            group.add(ADD);
            group.add(SUB);
            group.add(MUL);
            group.add(DIV);
            p2.add(ADD);
            p2.add(SUB);
            p2.add(DIV);
            p2.add(MUL);
            //Create buttons
            JButton NEXT = new JButton("NEXT");
            JButton END = new JButton("End");
            //Create Labels
            JLabel l1 = new JLabel("First num");
            JLabel l2 = new JLabel("Second num");
            JLabel l3 = new JLabel("Answer:");
            JLabel l4 = new JLabel("Score:");
            final JLabel l5 = new JLabel("");
            JLabel l6 = new JLabel("/");
            final JLabel l7 = new JLabel("");
            //Create Textfields
            final JTextField number = new JTextField(Generator1());
            final JTextField number2 = new JTextField(Generator1());
            final JTextField answer = new JTextField(5);
            //Add to panels
            p1.add(l1);
            p1.add(number);
            p1.add(l2);
            p1.add(number2);
            p1.add(l3);
            p1.add(answer);
            p1.add(l4);
            p1.add(l5);
            p1.add(l6);
            p1.add(l7);
            p3.add(NEXT);
            p3.add(END);
            //Add panels
            add(p2);
            add(p1);
            add(p3);
            //Create Listners
      NEXT.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
             int answer1 = 0;
             //Grab the numbers entered
             int numm1 = Integer.parseInt(number.getText());
             int numm2 = Integer.parseInt(number2.getText());
             int nummsanswer = Integer.parseInt(answer.getText());
             //Set the score and total into new variabls
             int nummscore = score;
             int nummtotal = total;
             //Check if the add radio button is selected if so add
             if (ADD.isSelected() == true){
                 answer1 = numm1 + numm2;
             //otherwise check if the subtract button is selected if so subtract
             else if (SUB.isSelected() == true){
                 answer1 = numm1 - numm2;
             //check if the multiplication button is selected if so multiply
             else if (MUL.isSelected() == true){
                 answer1 = numm1 * numm2;
             //check if the division button is selected if so divide
             else if (DIV.isSelected() == true){
                 answer1 = numm1 / numm2;
             //If the answer user entered is the same with th true answer
             if (nummsanswer == answer1){
                 //add to the total and score
                 nummtotal += 1;
                 nummscore += 1;
                 //Convert the input back to String
                 String newscore = String.valueOf(nummscore);
                 String newtotal = String.valueOf(nummtotal);
                 //Set the text
                 l5.setText(newscore);
                 l7.setText(newtotal);
             //Otherwise just increase the total counter
             else {
                 nummtotal += 1;
                 String newtotal = String.valueOf(nummtotal);
                 l7.setText(newtotal);
      //Create End listener
    END.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // get the root window and call dispose on it
            Window win = SwingUtilities.getWindowAncestor(p1);
            win.dispose();
    String Generator1(){
         int randomnum;
         randomnum = (1 + (int)(Math.random() * 20));
         String randomnumm = String.valueOf(randomnum);
         return randomnumm;
    public class Main {
         * @param args the command line arguments
        public static void main(String[] args) {
            // TODO code application logic here
            JFrame frame = new Grid();
            frame.setTitle("Flashcard Testing");
            frame.setSize(500, 200);
            frame.setLocationRelativeTo(null);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setVisible(true);
    }Edited by: SirSaula on Dec 5, 2009 4:39 PM

    Extract code into methods, so that when an action is performed a method is called. That way you can reuse the method for purposes such as resetting textfields to their default values, scores to default values, etc.
    You can go one step further and seperate the GUI layer from the processing layer, by deriving classes that for example maintain and calculate a score.
    Mel

  • Best way to make program wait for input from NI USB 9162?

    Hi, I'm somewhat new to Labview, but through all the tutorials and online help I'm still having trouble getting this to function properly.
    The USB adapter is hooked up to a network cable split into single wires reading in a voltage coming through several seperate oscillators.  
    Testing in the lab, the program included below works fine when I run the program, then quickly administer a shock to the table.  In the real world scenario though, I'm trying to make the program wait to record data until the first shock reaches the first oscillator before recording data, but I just can't seem to find an easy way to make this work.
    Attatched is an example of the program.  Any help would be greatly appreciated.  Thank you. 
    Attachments:
    Acq&Graph Voltage-Int Clk-rh-tt-1.vi ‏56 KB

      Hi,
    I think I have the answer you're looking for! Please see the attached VI.
    I moved the graph indicator inside the "true" case of the case structure. Before, your VI was sending data  to the graph from an empty timestamp constant with each iteration of the "false" case. Now the VI only sends data to the graph if a true is read.
    If you're wondering why it takes a bit of time for your graph to stop updating before it stops writing new data, it's because you're filling up a buffer of sampled data by using a queue. If you're writing to the buffer faster than you're reading from the buffer, you may encounter an "overflow" situation when the queue gets full. To avoid this, you might consider using a notifier rather than a queue. It's the exact same thing as a queue, but it gives you only the most recent value, allowing new values to overwrite old values.
    Hope this helps.
    Regards,
    Dan Richards
    Certified LabVIEW Developer
    Attachments:
    producer consumer DAQmx threshold.vi ‏57 KB

  • How do i make the program hold after it has created a JFrame

    I have created a JFrame with which the user shall login to a server. I call this JFrame from my main method (the JFrame-class is in a separate file). My problem is that after the login-window is created and set visible, my main method continues, i would like it to wait until the user have logged in before running the rest of the code.
    this i my main method:
    new LoginWindow();
    System.out.println("Logged in: "+Session.isLoggedin()+
                    "\nUsername: "+Session.getUsername());Session.isLoggedin() returns a boolean, true if user is logged in and otherwise false. class LoginWindow extends JFrame.
    i have tried to use a while-loop to solve my problem:
    while(!Session.isLoggedin()) { }and also
    whiel(true){
        if(Session.isLoggedin())
            break;
    }these while-loops never breaks, i have waited for about 3 min after successful login.It isn't because Session.isLoggedin() returns false, it does return true after a successful login (i've checked).
    the funny thing however is if i print something in the while-loop i does break when login is finished
    example:
    whiel(true){
        System.out.println(Session.isLoggedin());
        if(Session.isLoggedin())
            break;
    }this code makes the program wait until the login-phase is complete but i don't want it to print "text" a few thousand times while the user is logging in. (i've used "hej" as output aswell)
    Since i have no idea how long it will take for a user to log in i can't use the System.sleep(value) method.
    I would really appreciate any help
    Thanks in advance
    //Oscar

    SnuShogge wrote:
    I am still curious about why the while-loop only breaks if i print something using System.out.println(""), i didn't think that would make a difference since the break-statement remains the same.In general you should avoid trying to use while (true) or its variants in a Swing GUI as it often messes with the EDT, the main thread that renders the GUI graphics and interacts with the user.
    My problem i however partially solved by using a JDialog instead of a JFrame. I am planning on using JFrame later in the program so the problem might come back to haunt me if it isn't solved.This may not be a great idea. Usually an application has one single JFrame. Most other distinct windows a dialogs of one sort or another and should be JDialogs, not JFrames. Often better still is to use a CardLayout to swap JPanels or other components.

  • How can I make a bootable disk for Mountain Lion?

    How can I make a bootable disk for Mountain Lion?

    Make Your Own Mountain/Lion Installer
    1. After downloading Mountain/Lion you must first save the Install Mac OS X Mountain/Lion application. After Mountain/Lion downloads DO NOT click on the Install button. Go to your Applications folder and make a copy of the Mountain/Lion installer. Move the copy into your Downloads folder. Now you can click on the Install button. You must do this because the installer deletes itself automatically when it finishes installing.
    2. Get a USB flash drive that is at least 8 GBs. Prep this flash drive as follows:
    Open Disk Utility in your Utilities folder.
    After DU loads select your flash drive (this is the entry with the mfgr.'s ID and size) from the left side list. Click on the Partition tab in the DU main window.
    Under the Volume Scheme heading set the number of partitions from the drop down menu to one. Set the format type to Mac OS Extended (Journaled.) Click on the Options button, set the partition scheme to GUID then click on the OK button. Click on the Partition button and wait until the process has completed.
    Select the volume you just created (this is the sub-entry under the drive entry) from the left side list. Click on the Erase tab in the DU main window.
    Set the format type to Mac OS Extended (Journaled.) Click on the Options button, check the button for Zero Data and click on OK to return to the Erase window.
    Click on the Erase button. The format process can take up to an hour depending upon the flash drive size.
    3. Locate the saved Mountain/Lion installer in your Downloads folder. CTRL- or RIGHT-click on the installer and select Show Package Contents from the contextual menu. Double-click on the Contents folder to open it. Double-click on the SharedSupport folder. In this folder you will see a disc image named InstallESD.dmg.
    4. Plug in your freshly prepared USB flash drive. You are going to clone the content of the InstallESD.dmg disc image to the flash drive as follows:
    Double-click on the InstallESD.dmg file to mount it on your Desktop.
    Open Disk Utility.
    Select the USB flash drive from the left side list.
    Click on the Restore tab in the DU main window.
    Select the USB flash drive volume from the left side list and drag it to the Destination entry field.
    Drag the mounted disc icon from the Desktop into the Source entry field.
    Double-check you got it right, then click on the Restore button.
    When the clone is completed you have a fully bootable installer that you can use without having to re-download Mountain/Lion.
    Note: The term Mountain/Lion used above means Lion or Mountain Lion.

  • How can I make a "property node" for a VI?

    Hello!
    If I add a boolean button on the FP then I am able to make a property node for that button in the Block Diagram. But how can I make a property node for a VI? I have several VI:s an that together is one program. What I need to do is to verify what kind of VI some of my VI:s is. I need to verify if it is .exe or .vi-file, and if it is .exe then I want to disable run, abort, run continuously bottons otherwise not. I have hard that this is possible to do programmaticaly but I can´t figure out how. I am aware that I could do that manually in the File->vi properties->customize->windows appearance but theese choises makes it last forever.
    I want to be able to stop and run and everything if it is a .vi file, but if it is .exe-file then all those buttons should be disabled.
    Anyone have an example on this?
    In an other message at this Forum I read "You can use the `Front Panel Window. Allow Runtime PopUp`" property to disable run-time shortcuts menues programmaticaly, but still I dont know how to create this property node.
    /Amir

    You really shouldn't open a new thread. If you don't understand something, ask and we will explain it.
    Like I said in the other thread, you can check if you are running in LV or an EXE by using the Application>>Kind property. To get it, place a property node (from the Application Control palette) on the diagram, click it and find the property.
    To set the properties for the VI, place another property node, right click it and select Select Class>>VI Server>>VI. You should have the properties you want under Front Panel Window.
    To learn more about LabVIEW, I suggest you try searching this site and google for LabVIEW tutorials. Here and here are a couple you can start with. You can also contact your local NI office and join one of their courses.
    In addition, I suggest you read the LabVIEW style guide and the LabVIEW user manual (Help>>Search the LabVIEW Bookshelf). I believe chapter 17 of the user manual explains about programmatic control of VIs.
    Try to take over the world!

  • Since ios 6 update hotmail fetches or push on its own. I have hotmail set to manual. Best I can tell its only hotmail and not yahoo. Is this a known problem? How do I make hotmail stop checking for mail when I have it set to manual?

    Since ios 6 update hotmail fetches or push on its own. I have hotmail set to manual. Best I can tell its only hotmail and not yahoo. Is this a known problem? How do I make hotmail stop checking for mail when I have it set to manual?

    Hello,
    '''Try Firefox Safe Mode''' to see if the problem goes away. Safe Mode is a troubleshooting mode, which disables most add-ons.
    ''(If you're not using it, switch to the Default theme.)''
    * On Windows you can open Firefox 4.0+ in Safe Mode by holding the '''Shift''' key when you open the Firefox desktop or Start menu shortcut.
    * On Mac you can open Firefox 4.0+ in Safe Mode by holding the '''option''' key while starting Firefox.
    * On Linux you can open Firefox 4.0+ in Safe Mode by quitting Firefox and then going to your Terminal and running: firefox -safe-mode (you may need to specify the Firefox installation path e.g. /usr/lib/firefox)
    * Or open the Help menu and click on the '''Restart with Add-ons Disabled...''' menu item while Firefox is running.
    [[Image:FirefoxSafeMode|width=520]]
    ''Once you get the pop-up, just select "'Start in Safe Mode"''
    [[Image:Safe Mode Fx 15 - Win]]
    '''''If the issue is not present in Firefox Safe Mode''''', your problem is probably caused by an extension, and you need to figure out which one. Please follow the [[Troubleshooting extensions and themes]] article for that.
    ''To exit the Firefox Safe Mode, just close Firefox and wait a few seconds before opening Firefox for normal use again.''
    ''When you figure out what's causing your issues, please let us know. It might help other users who have the same problem.''
    Thank you.

  • How can i make simple program to match colors ?(photos taken by camera)

    how can i make simple program to match colors ?(photos taken by camera)

    Hi khaledyr,
    use a "random number" and compare for ">0.5" to get a (1 or 0) signal
    What exactly are you searching for?
    - Hints for choosing hardware?
    - How to output voltage or relais signals?
    - Help on using DAQ(mx)?
    - Help on generating (boolean) waveforms?
    Message Edited by GerdW on 04-16-2010 08:15 AM
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

Maybe you are looking for

  • CAN we upload data periodically in LSMW?

    HI Expert,                  In LSMW , maintain object attributes step , there is periodic option if we select that option then  would the data transfer periodically?How does it differ from periodic in BDC? LSMW we can not schedule  updation write? we

  • ITunes 10.6 radio cannot connect to the radio tuning service.

    I still can access the iTunes store. What is the issue here?

  • Editable Blocked ALV

    HI,     I have created a Blocked ALV with 2 blocks.. first block is editable by the user , I want to store the editted date into my Internal table for further processing.. Kindly guide me how to do.. Plz dont give any links... all sites are blocked h

  • Comparing SELECTs for performance

    I have a long-running function module and through SAT, I've identified its SELECT from BSEG as a potential hotspot and way that I can improve the run time, etc. Through some research in SCN, I found I can/should use one of the component tables (BSID)

  • Re: "You are currently restricted from purchasing ...

    i have the same problem and i had contacted to the support tem by sending the form but i stilll wating for the reply. Any one help plssssssssssssssssssss