How would I set this small program to activate every 120 seconds?

I have this small program that writes the value 0 to a file, but I want it to only activate every 120 seconds, so it doesn't take up a bunch of system resources by constantly running. Can I make it pause for 120 seconds, or set a timer for it, in such a way that it won't make my PC run slow? Here's my code. Thanks if you can help.
import java.util.*;
import java.io.*;
import java.io.File;
public class Purge extends Random implements Serializable {
     public Purge () {
          writePrimDoubles();
     public static void main (String [] args) {
          Purge test = new Purge();
     public void writePrimDoubles() {
          DataOutputStream outStream;
          long timerStart;
          long timerEnd;
          long size;
          int a = 1;
          try     {          
               while (a==1) {
                    outStream = new DataOutputStream
                         (new FileOutputStream("packetlog.txt"));
                    timerStart = System.currentTimeMillis();
                    outStream.writeBytes("0");
                    timerEnd = System.currentTimeMillis();
                    outStream.close();
          catch(IOException e) {
               System.out.println("Error writing to file");
}

java.util.Timer, I think may do the trick.

Similar Messages

  • I would like a program to run every time the computer boots. How would I set this up?

    I would like a program to run everyime the computer boots but am not sure where to go to set that up.

    Either of two places.
    If the program's icon is in the Dock, right-click or Control-click on that icon, then from the Options item select Open at Login.
    Otherwise, go to System Preferences > Accounts (in Snow Leopard) or Users & Groups (in Lion). Select the account in the left pane, then click Login Items in the selector bar near the top of the screen. Use the "+" button to add the item you want.

  • How Would You Do This Effect in Logic?

    I'm trying to figure out how I would best achieve the vocal effect in Kesha's song "BLOW."
    http://www.youtube.com/watch?v=_USZ2D0GTxo
    In the chorus, there is the catchy "blow....oh...oh..oh..oh..oh..oh" section. Someone suggested she sings the entire line, which gets interrupted by a gate, which could be triggered by a keyboard, so everytime you hit a note, it stops the steady note she's singing. If you guys think that's what they are doing, how would I set this up? This kind of thing goes on in modern pop all the time and I have to find a way to do this effect before it drives me crazy;)
    I get hired to do karaoke tracks all the time and whenever there is one these to day it is always a pain due to my being more a traditional guitar, keyboard "organic" producer than synth/FX guy.
    Thanks for any help.
    Tom

    Thanks David.
    The plug ins you mention don't really help though, because they can only be set to preset patterns. This is a specific pattern of course. I know The Bee Gees did this in Robin Gibb song from the 80s called "Boys Do Fall In Love" ....there was a section that went "B......B...B...Boys fall in love." They did it by sampling the phrase into the Emulator back then and playing the phrase. I guess I could do that with EXS.
    The best solution would be if there was a way to make a gate respond to a midi track, so I could play the rhythm on the midi track, quantize it, then use that as a trigger to the gate...gonna try that...Guess I could also record the midi track as a sidestick or something and use that audio track to trigger the gate....hmmmm.
    Tom

  • I would like to delete emails on my PC when I delete them on my Ipad (and vice versa, if possible).  How do I set this up?  Thanks.

    I would like to delete emails from my PC when I delete them from my Ipad (and vice versa, is possible).  How do I set this up?  Thanks in advance.

    The ability to do that would depend on the type of email account that you have. If it is a POP account, it cannot be done. If it is an IMAP account, it should sync across devices automatically. If you are not sure what type of account it is, who is your email provider?

  • I want to reset my bootcamp Windows 7 to factory setting. How would I do this without damaging or effecting my Mac data?

    I want to reset my bootcamp Windows 7 to factory setting. How would I do this without damaging or effecting my Mac data?

    If you want to erase the BootCamp Partition, you'd use the Bootcamp utility.
    Then that part of the Mac's hard disk drive may be available for use in OS X.
    {Or, if you want to install a clean Windows 7 in the same BootCamp partition
    you'd use the BootCamp utility to erase/install Windows in the same location.
    There is a BootCamp Support section in Apple Support online, and also there
    is a fairly OK ASC discussions area specific to that purpose. }
    But you may have to check to see if the partition map is correct for Mac OS X
    after you've used Bootcamp utility to remove Windows and the partition map.
    If you do not use the BootCamp utility to remove Windows, correctly or if a
    different method to install Windows was used, you'd have to move your Mac
    OS X system and applications off the computer to an external hard drive by
    use of a clone utility (carbon copy cloner, or superduper, etc) then use the
    OS X disk utility (from running clone, is easiest) to erase the computer's HD
    and then correctly partition map and format the hard drive for Mac OS X.
    At that point, the entire drive would be erased to reclaim any untouched
    partitions from alternative Windows utilities that were used, or not used in
    the time frame of proper opportunity.
    I've had a few Macs that had been partitioned for Windows and found one
    second hand MacBook to have more actual hard disk drive capacity than
    the previous owner and the Mac HD info suggested on first glance. About
    70% of the drive had been a Windows partition, but was invisible to OS X.
    So that turned out to be a lucky find, it was like installing a larger HDD.
    The wording of your question leaves a lot
    of important information out of the picture.
    Good luck!
    edited

  • How would I fix this AppleScript error?

    So I'm trying to do a square root so lets use the example of:
    set x to -11
    set y to -11 ^ (1 / 2)
    It then returns error number -2702, how would I fix this error?

    AppleScript can't recognize or use imaginary numbers. If you need to use these, use a program which can.
    (66383)

  • Hi, I want to use my Capsule just as a back up via wireless. How do I set this up without connecting it with an ethernet cable to either a router or the iMac??

    Hi, I want to use my Capsule just as a back up via wireless. How do I set this up without connecting it with an ethernet cable to either a router or the iMac??

    I misunderstood what Time Capsule is and had hoped for a wireless backup device that didn't have to be connected to the router.
    The TC is a wireless backup device.. it does not need to be connected to the main router..
    The problem is the computer.. not the TC.. the computer has only one wireless card.. if your current internet is by wireless.. then you must choose.. internet or backup.
    But my other suggestion will work.. get a wireless USB stick compatible with Mac OS.. there are plenty and cheap.. since you are in the same room as the TC they will work fine.. plug it in and load the driver.. taint hard.
    You should do the first backup by ethernet though.. wireless is too slow.. once you have that, you will do fine.
    Search ebay for wireless n usb.. Mac compatible..
    http://www.ebay.com/itm/New-EDUP-Mini-Wireless-11N-300M-USB-LAN-Card-WiFi-Adapte r-Nano-Card-Soft-AP-/150864362939?pt=US_USB_Wi_Fi_Adapters_Dongles&hash=item2320 377dbb#ht_3553wt_1165
    As you can see.. they are getting smaller and neater.
    I have no idea if it works .. haven't tried one.. but I have used USB wireless stick on the Mac to overcome this issue.
    You will need to set static IP .. not hard but you need to set specifics if you do buy one post again for the setup.

  • E-mail synch, read/unread, how can I set this up?

    I'd like to refer to an older question I found which hadn't been answered properly.
    https://discussions.apple.com/thread/3557308?start=0&tstart=0
    Quite simply, the question is;
    I have my work e-mail, my Hotmail and my Gmail all set-up on my iPhone 4S and my iPad 1st gen.
    When I read an e-mail on the computer via browser or outlook, I would like for this e-mail to appear as READ on my devices as well.
    Vise versa for when I read it on the iPad/Phone and I want that e-mail to show as read on Outlook and browser.
    Because this doesn't happen automatically, the Mail icon on my home screen is constantly showing over 1K e-mails, when in reality I may have like 10 on each e-mail account.
    How can I set this up?
    Is it possible for my to set this up for deleting e-mails also?
    I know I can do that on Gmail, delete from server blah blah, but how about when I delete e-mail from Outlook...I want them to be off my phone also.
    It's a business e-mail, and I get like over 50 read/received notifications that spam my inbox.
    Thank you for taking the time to read and for any advice you may have.

    Please go to
    1.Setting
    2. mail,contacts and calenders
    3. add accounts
    4. insert your email account and password
    5. Autometically imports your mails if you open mail folder on the desktop..
    That is it.

  • How would I do this?

    I have to say I'm completely lost. I need to make two files - WordFrequencyAnalyzer.java that has all the functions and TestWordFrequencyAnalyzer.java that should be a GUI that calls the first one. I know how to make GUIs without a problem but its these functions that baffle me.
    This is what I need to do - WordFrequencyAnalyzer.java needs to have a constructor that opens us a text file and reads it and saves what is needed for analysis. This is what I have:
    public void WordFrequencyAnalyzer(String filename) throws IOException
         {//Constructor.  Uses file name to open file reads it, saving what is needed, then closes the file.
               BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(filename))));
         }Now these are killing me:
    public int frequency(String word)
    *****This needs to be able to check the number of times the particular word occurs in the file. How would I do this? Please help give me a clue. The next few seem to tie in together if I could figure out how to do one of them.
    public String mostFrequentWord()
    //The word that occurs most often in the file
    public String[] wordsOccurringAtLeast(int minimumNumberOfTimes)
    //An array, alphabetized, of all the words occurring at least the given minimum number of times...I'd figure I'd use a search and compare method here.
    public int numberOfWords()
    //The number of words (counted once each) in the file
    public String toString()
    //Returns a string which, when printed, will show two columns, with a word on each line on the left and its frequency on the right. The result must be alphabetized.
    Who could give me some pointers. I don't want the code done for me because I need to learn too. Do I need to put the data from the text file into a Collection interface in the java.util package or should I use something else?? And how would I go about doing something like that?
    Thank you very much,
    Henry

    I modified the code above for the Hashtable to a Collection and came up with this and emailed him:
         What about this:
         Collection words = new Collection();
         String line;
         while ((line = br.readLine()) != null)
         StringTokenizer st = new StringTokenizer(line);
         while (st.hasNext())
         { words.add(st.next().toString());
         Storing in a Collection is what you want right? I don't want to do something that you don't approve of. I remember the time I used a Hashtable and you didn't like it. ...
    This is his response:
    As for your suggested solution: A collection is a good idea, but Collection is
    an interface, so you can't do anything like
    Collection words = new Collection();
    You must figure out what kind of collection to use. And here's a hint about
    something else:
    If every time you see a word like "the" you store it in the collection, you'll
    have two problems: the word will be stored over and over, which is inefficient
    use of space, and your program will have to do a lot of repetitive work to
    implement the methods, which is inefficient use of time.
    I new he wanted a Collection. I'm starting to know him a little better now I guess, which still doesn't help as much. If anyone has any ideas please post - this is all new to me. Does anyone know the best kind of Collection to use as he put it?
    Thanks,
    Henry

  • I am a Brit living in Germany. I really need to be able to purchase from the German iTunes Store (in €) and the English one (in £). How can I set this up from my iPad?

    I am a Brit living in Germany. I really need to be able to purchase from the German iTunes Store (in €) and the English one (in £). How can I set this up from my iPad?

    Technically correct (the best kind of correct)
    Now if the Op has and retains a UK account with billing address and UK paymant card - He/She can continue to use the UK store in Germany - Apple does NOT use IP address blocking just a valid paymant card attached to a postcode !
    Basically the first four of your paymant card are country codes.
    What the op needs to do if he/she now has a Germany address and payment method (could just be German € value gift cards) is to open a separate German iTunes Account !
    On a PC/Mac its very easy to change stores, however iOS has it a bit more difficult.
    In fact i would recommend the Op sets up a new German account and credentials on a PC/Mac first.
    And doing so just means opening the store in iTunes scrolling to the bottom of the screen and clicking on the littler circular flag in the bottom right.
    After that the browser window is populated with loads of similar disc flags. Clicking any take you to that regional store where provided you have a valid address (Postcode/Zipcode actually) and payment method local credit/debit some prepayment VISA cards or just a gift card you can create a local account.
    Oh and because Apple do NOT use IP addressing you don't actually have to be present in the country of that store. Its against to terms of the EULA but it works !
    Back to the iOS device
    Tap Settings/iTunes & App Store /Apple ID (that will probably be showing the UK account set up).
    In the window that opens tap log out
    Now  change the ID to the new German name and password and in the next window make sure the flag selected is that of Germany (when in Germany)
    When buying from the UK store follow that path again log out of the German account and re-log in using the UK ID
    As it happens I have a UK Portuguese and US account all active because I have residences in all three - and can visit any of the stores from anywhere.

  • I need to change my apple id in my ipod (it was an old email address).  How would you do this?

    I need to change my apple ID in my ipod touch (it was an old email address).  I have changed to setting in itunes.  How would you do this? - not sure what my OS is.

    Go to Settings>Store (or Settings>iTunes and App Stores for iOS 6) and sign out and sign in with the other/updated account.

  • Advice - how would you do this?

    I have a compound path (an inner rectangle and an outer one) in an opacity mask. I have to apply an b/w gradient from the outer to the inner ractangle.
    I can only find a feature to add circular an linear gradients!
    How would you do this?

    haemse,
    Transitions like this are made with Blends; Object>Blend>Options to ensure the options you want, then Object>Blend>Make.
    In this case you may:
    1) Object>Compound Path>Release;
    2) For each rectangle, set Stroke to the Fill Color and set Fill to None;
    3) Select both and Object>Blend>Make (keep it Smooth).
    In other words replace the Compound Path with a Blend.

  • How do I use the time capsule to share itunes music between multiple apple devices? Also, is it possible to control the music on one device using another, and how do you set this up?

    How do I use the time capsule to share itunes music between multiple apple devices? Also, is it possible to control the music on one device using another, and how do you set this up?

    unless i'm missing something, i think you got mixed up, this is easy google for walk throughs
    i'm assuming this is the new 3tb tc AC or 'tower' shape, if so, its wifi will run circles around your at&t device
    unplug the at&t box for a minute and plug it back in
    factory reset your tc - unplug it, hold down reset and keep holding while you plug it back in - only release reset when amber light flashes in 10-20s
    connect the tc to your at&t box via eth in the wan port, wait 1 minute, open airport utility look in 'other wifi devices' to setup the tc
    create a new wifi network (give it a different name than your at&t one) and put the tc in bridge mode (it may do this automatically for you, but you should double check) under the 'network' tab
    login to your at&t router and disable wifi on it
    add new clients to the new wifi network, and point your Macs to the time machine for backups

  • I share my iTunes with my family's iPods.  We all buy music on our iPod's and would like to transfer the purchases to the iTunes library.  How would we do this?

    I share my iTunes with my family's iPod's.  We all buy music seperately on our own iPod and would like to transfer the music to our iTunes library, how would we do this?

    Oh jeez, that was simple. Thanks!

  • I bought my daughter an ipod. Can I have two seperate itunes libraries on one computer? If so, how do I set this up?

    I bought my duaghter an ipod. Can I have two seperate itunes libraries on one computer? If so, how do I set this up?

    I followed these instructions & have created a new library file. However, all my music now appears in the new library as well as my own. (I bought my daughter an ipod nano for christmas & want to separate itunes libraries on one computer). How can this be so difficult?

Maybe you are looking for

  • Satellite C50-A-1FT - How to boot from the USB stick

    hi, this is last stop really as have run out of ideas,have asked every techie that know including taking it to an independant computer store. I am using a toshiba satelite C55 a-1d5, with windows eight preinstalled. I am trying to get Ubuntu booting

  • Using order by and rownum in massive tables

    Hi, I need to retreive paginated and ordered data from a big table. I know some different tips using rownum or the RANK() function and subqueries, these tips work well for small amount of data, but I need to get the data from a table with 200.000 ent

  • Broadcast in BEX Analyzer

    We are running on BI 7.0 SP10. Bex Analyzer 7.0 is running and dashboards are usings. Is it possible to broadcast BEX Analyzer reports within dashboard

  • Using RoboHelp for Product Branding

    My company wants me to be able to use a single source file to create different versions of HTML help and printed documentation for product branding. Is there a way to simply put in a variable like <product name> or <screen name> in the source file? S

  • Error when use concatenate in se38

    Hi , I want to generate a file for which i have written a code to populate the fields of an internal table. Now when the fields have got values, i am trying to use only the necessary fields and put them in a file, so that i can load that file into a