Is Runtime.exec() the only way?

i'm trying to run some shell commands from a java program, which would normally take a minute to complete running on a 1.2 GHz processor and using 98% of the processor time. when i make a Runtime.getRuntime.exec() and add a waitFor() call for these processes, the computer doesn't even give the process a 1% share of the processor. So, having the java program waitFor() the process stalls the (java) program, while not including the waitFor() call would make the java program call way too many instances of the shell process. I don't want to use a .wait(time) call because i want to make my code as tight as i can and that still runs the risk of overlapping processes.
So, my question is, how do i call an outside program, give it the resources it needs, and wait until the process finishes to move on to the next step in my java program?
here's the code i'm using, if that helps at all ("params" is a string with a shell command - this is the code that makes the java program hang):
while(?)
     Process proc = Runtime.getRuntime().exec(params);
     proc.waitFor();
}(while this would be the code to make the java program call too many instances of the process):
while(?)
     Runtime.getRuntime().exec(params);
}

Ahh, a good ol' case of RTFM by me - my bad!
thanks for directing me to that article; i think all works now =)
     Process proc = Runtime.getRuntime().exec(params);
     StreamGobbler errorGobbler = new StreamGobbler(proc.getErrorStream(), "ERROR");
     StreamGobbler outputGobbler = new StreamGobbler(proc.getInputStream(), "OUTPUT");
     errorGobbler.start();
     outputGobbler.start();
     int exitVal = proc.waitFor();where StreamGobbler is a class that guy in the article made.
i hope i'm allowed to do this - the article is here: http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

Similar Messages

  • Since updating an iphone5 to ios8.3, it is no longer recognized by my pc. An Apple tech suggested that I install itunes as the only way to assure that I have the latest driver. Any way to do this without installing itunes?

    Since updating an iphone 5 to ios 8.3, it is no longer recognized by my Windows 7 pc. An Apple tech suggested that I install itunes as the only way to assure that I have the latest driver. Any way to do this without installing itunes?

    Read this
    Syncing to a "New" Computer or replacing a "crashed" Hard Drive

  • I have ios 5.1.1. When I sync to iTunes, my purchased apps no longer work. They blink but do not open. The only way I have been able to solve this, is as follows: I delete one of the apps and then re-download and install it. Then, all my apps work.

    My new iPod touch 64 Gig has a problem after syncing with iTunes. My purchased apps no longer work. I touch them and they seem to try to open but they do not.
    The only way I have found to fix this is as follows:
    I delete one of the purchased apps. Then I go to the App Store and re-download and install the same app. After that, all my apps work again.
    Please help.

    Download/install an app is a know possible solution.
    3. Install another app from the App Store
    If all user-installed apps are not launching, it could be an Apple ID authorization issue. Download and install an app that isn't already installed on your device to reset this information.
    Note: If you have installed apps using multiple Apple ID accounts, you may need to perform this step for each account.
    Above from Apple's :
    iOS: Troubleshooting applications purchased from the App Store

  • How do I stop Firefox from creating untitled web pages when I try to send email from a web page. The only way I have found is to turn the computor off and then reboot. I don't have this problem when using Internet Explorer

    Every time I click on a web site that has an email option the browser starts making untitled web pages and never stops unless I turn the computer off. It is very frustrating to not be able to use an email option when offered by a web site. The only way I can send email messages on the Firefox browser is to go into my hotmail acct. and copy and paste the addresses. I don't have this problem when I use the Internet Explorer browser.

    See [[Firefox keeps opening many tabs or windows]]

  • After reading and resetting everything with Keyboard I still get blank white screen. The only way I can boot to Mavericks is unplug power cord, push and hold power button while plugging power cord in. Fans at full speed.

    After reading and resetting everything with Keyboard I still get blank white screen on 2nd? page of boot. The only way I can boot to Mavericks is unplug power cord, push and hold power button while plugging power cord in. Fans run at full speed, machine boots then runs normal except the dvdrw will not . The mid 2011 IMAC had the same problem with LION. I changed hard drives, formatted, and installed a clean install of latest os x mavericks. Any help would be greatly appreciated.
    EtreCheck version: 1.9.15 (52)
    Report generated August 30, 2014 at 6:56:41 PM EDT
    Hardware Information: ?
        iMac (21.5-inch, Mid 2011) (Verified)
        iMac - model: iMac12,1
        1 2.5 GHz Intel Core i5 CPU: 4 cores
        4 GB RAM
    Video Information: ?
        AMD Radeon HD 6750M - VRAM: 512 MB
            iMac 1920 x 1080
    System Software: ?
        OS X 10.9.4 (13E28) - Uptime: 0 days 0:16:53
    Disk Information: ?
        ST3120026AS disk0 : (120.03 GB)
        S.M.A.R.T. Status: Verified
            EFI (disk0s1) <not mounted>: 209.7 MB
            Untitled (disk0s2) / [Startup]: 119.17 GB (87.12 GB free)
            Recovery HD (disk0s3) <not mounted>: 650 MB
        HL-DT-STDVDRW  GA32N 
    USB Information: ?
        Apple Inc. FaceTime HD Camera (Built-in)
        CHICONY USB NetVista Full Width Keyboard
        Apple Inc. BRCM2046 Hub
            Apple Inc. Bluetooth USB Host Controller
        Apple Computer, Inc. IR Receiver
        Apple Internal Memory Card Reader
    Thunderbolt Information: ?
        Apple Inc. thunderbolt_bus
    Gatekeeper: ?
        Anywhere
    Kernel Extensions: ?
        [loaded]    com.nvidia.CUDA (1.1.0) Support
        [loaded]    com.sophos.kext.sav (9.0.61 - SDK 10.7) Support
        [loaded]    com.sophos.nke.swi (9.0.53 - SDK 10.8) Support
    Startup Items: ?
        CUDA: Path: /System/Library/StartupItems/CUDA
        FanControlDaemon: Path: /Library/StartupItems/FanControlDaemon
    Launch Daemons: ?
        [loaded]    com.adobe.fpsaud.plist Support
        [running]    com.arcsoft.eservutil.plist Support
        [running]    com.bjango.istatmenusdaemon.plist Support
        [loaded]    com.oracle.java.Helper-Tool.plist Support
        [running]    com.sophos.autoupdate.plist Support
        [running]    com.sophos.configuration.plist Support
        [running]    com.sophos.intercheck.plist Support
        [running]    com.sophos.notification.plist Support
        [running]    com.sophos.scan.plist Support
        [running]    com.sophos.sxld.plist Support
        [running]    com.sophos.webd.plist Support
    Launch Agents: ?
        [running]    com.arcsoft.esinter.plist Support
        [running]    com.bjango.istatmenusagent.plist Support
        [loaded]    com.nvidia.CUDASoftwareUpdate.plist Support
        [loaded]    com.oracle.java.Java-Updater.plist Support
        [running]    com.sophos.uiserver.plist Support
    User Login Items: ?
        Macs Fan Control
        Firefox
    Internet Plug-ins: ?
        FlashPlayer-10.6: Version: 14.0.0.176 - SDK 10.6 Support
        Flash Player: Version: 14.0.0.176 - SDK 10.6 Support
        QuickTime Plugin: Version: 7.7.3
        JavaAppletPlugin: Version: Java 7 Update 67 Check version
        Default Browser: Version: 537 - SDK 10.9
    Audio Plug-ins: ?
        BluetoothAudioPlugIn: Version: 1.0 - SDK 10.9
        AirPlay: Version: 2.0 - SDK 10.9
        AppleAVBAudio: Version: 203.2 - SDK 10.9
        iSightAudio: Version: 7.7.3 - SDK 10.9
    iTunes Plug-ins: ?
        Quartz Composer Visualizer: Version: 1.4 - SDK 10.9
    3rd Party Preference Panes: ?
        CUDA Preferences  Support
        Fan Control  Support
        Flash Player  Support
        Java  Support
    Time Machine: ?
        Time Machine not configured!
    Top Processes by CPU: ?
             1%    WindowServer
             1%    fontd
             0%    firefox
             0%    SystemUIServer
             0%    SophosWebIntelligence
    Top Processes by Memory: ?
        229 MB    firefox
        156 MB    SophosScanD
        152 MB    InterCheck
        131 MB    com.apple.IconServicesAgent
        115 MB    SophosAntiVirus
    Virtual Memory Information: ?
        424 MB    Free RAM
        1.53 GB    Active RAM
        1.37 GB    Inactive RAM
        699 MB    Wired RAM
        1.26 GB    Page-ins
        0 B    Page-outs

    I'd start by getting rid of the following software responsible for these extensions.
    Kernel Extensions: ?
        [loaded]    com.nvidia.CUDA (1.1.0) Support
        [loaded]    com.sophos.kext.sav (9.0.61 - SDK 10.7) Support
        [loaded]    com.sophos.nke.swi (9.0.53 - SDK 10.8) Support
    Startup Items: ?
        CUDA: Path: /System/Library/StartupItems/CUDA
        FanControlDaemon: Path: /Library/StartupItems/FanControlDaemon
    Use the uninstaller provided with the Sophos software. You can uninstall CUDA via the preference pane. Be sure you remove the com.nvidia.CUDA extension which is located in the /System/Library/Extensions/ folder. Not sure if Fan Control has an uninstaller so you will have to do it manually:
    Uninstalling Software: The Basics
    Most OS X applications are completely self-contained "packages" that can be uninstalled by simply dragging the application to the Trash.  Applications may create preference files that are stored in the /Home/Library/Preferences/ folder.  Although they do nothing once you delete the associated application, they do take up some disk space.  If you want you can look for them in the above location and delete them, too.
    Some applications may install an uninstaller program that can be used to remove the application.  In some cases the uninstaller may be part of the application's installer, and is invoked by clicking on a Customize button that will appear during the install process.
    Some applications may install components in the /Home/Library/Applications Support/ folder.  You can also check there to see if the application has created a folder.  You can also delete the folder that's in the Applications Support folder.  Again, they don't do anything but take up disk space once the application is trashed.
    Some applications may install a startupitem or a Log In item.  Startupitems are usually installed in the /Library/StartupItems/ folder and less often in the /Home/Library/StartupItems/ folder.  Log In Items are set in the Accounts preferences.  Open System Preferences, click on the Accounts icon, then click on the LogIn Items tab.  Locate the item in the list for the application you want to remove and click on the "-" button to delete it from the list.
    Some software use startup daemons or agents that are a new feature of the OS.  Look for them in /Library/LaunchAgents/ and /Library/LaunchDaemons/ or in /Home/Library/LaunchAgents/.
    If an application installs any other files the best way to track them down is to do a Finder search using the application name or the developer name as the search term.  Unfortunately Spotlight will not look in certain folders by default.  You can modify Spotlight's behavior or use a third-party search utility, EasyFind, instead.
    Some applications install a receipt in the /Library/Receipts/ folder.  Usually with the same name as the program or the developer.  The item generally has a ".pkg" extension.  Be sure you also delete this item as some programs use it to determine if it's already installed.
    There are many utilities that can uninstall applications.  Here is a selection:
        1. AppZapper
        2. AppDelete
        3. Automaton
        4. Hazel
        5. AppCleaner
        6. CleanApp
        7. iTrash
        8. Amnesia
        9. Uninstaller
      10. Spring Cleaning
    For more information visit The XLab FAQs and read the FAQ on removing software.
    Be sure to remove your two Login Items. Finally do this:
    Reinstall Lion, Mountain Lion, or Mavericks without erasing drive
    Boot to the Recovery HD:
    Restart the computer and after the chime press and hold down the COMMAND and R keys until the menu screen appears. Alternatively, restart the computer and after the chime press and hold down the OPTION key until the boot manager screen appears. Select the Recovery HD and click on the downward pointing arrow button.
    Repair
    When the recovery menu appears select Disk Utility. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported then click on the Repair Permissions button. When the process is completed, then quit DU and return to the main menu.
    Reinstall Lion, Mountain Lion, or Mavericks
    OS X Mavericks- Reinstall OS X
    OS X Mountain Lion- Reinstall OS X
    OS X Lion- Reinstall Mac OS X
         Note: You will need an active Internet connection. I suggest using Ethernet
                     if possible because it is three times faster than wireless.

  • I forgot my Apple ID security question answers and cannot contact iTunes support by phone. The only way I can ask for help is via email. How can I make that happen?             Thanks

    Hi! So I haven't used iTunes in a few months but I just got an iTunes gift card and want to make a purchase. iTunes redeemed it just fine but now that I want to make a purchase I am having problems. I can't remember my security question answers and iTunes is requesting them. I have two other verified emails but the are NOT rescue emails. I can't contact iTunes over the phone because my phone lines are out and are going to be out for a long time. The only way I can contact them is by email. How can I do this? Is there an easy way to just reset all my security questions? Please help a girl out. I just want my music!
    Thanks so much

    Alternatives to Reset Security Questions and Rescue Mail
         1. Apple ID- All about Apple ID security questions.
         2. Rescue email address and how to reset Apple ID security questions
         3. Start here to find your country, and how you can contact Apple:
             Apple ID- Contacting Apple for help with Apple ID account security.
         4. Fill out and submit this form. Select the topic, Account Security.
         5.  Call Apple Support in your country and ask to speak to Account Security.
              Customer Service: Contacting Apple for support.
    How to Manage your Apple ID: Manage My Apple ID

  • I am unable to open new tabs, in any way I attempt to do so. I have checked the settings and they are fine, so it's not those. The only way I can open a new tab is to right click on a link and instruct it to open in a new tab.

    Any way I attempt to open new tabs, be it clicking on the new tab button or using the short-cut Ctrl-t, I am unable to open any new tabs on my browser window.
    The only way I have found that I can open a new tab is to right-click on a link and instruct that link to open in a new window.

    Try disabling the Ask Toolbar extension.

  • The only way I can open a new tab is by right-clicking a bookmarked site and selecting "Open in a New Tab." I can't click on the New Tab + or CTR+T or open via File. WHY?!?

    The only way I can open a new tab in Firefox is by right-clicking a bookmarked site and selecting "Open in a New Tab." I can't click on the New Tab + or CTR+T or open via File. WHY don't the other means work?

    The Ask Toolbar is causing that in the Firefox 3.6.13+ versions. Uninstall that extension.
    There are a couple of places to check for the Ask toolbar:
    * Check the Windows Control panel for the Ask Toolbar - http://about.ask.com/apn/toolbar/docs/default/faq/en/ff/index.html#na4
    * Also check your list of extensions, you may be able to uninstall it from there - https://support.mozilla.com/kb/Uninstalling+add-ons

  • Whenever I reply to an e-mail the window comes up but without the paper airplane in the top left corner.  The only way to send the reply is to close it and save as a draft.  Then I can pull it up from Drafts and it has the airplane on it.

    Whenever I reply to an e-mail the window comes up but without the paper airplane in the top left corner.  The only way to send the reply is to close it and save as a draft.  Then I can pull it up from Drafts and it has the airplane on it.

    Launch Mail.
    Click "New Message" in the Toolbar.
    When the new message window opens up, click "View" menu in the menu bar.
    Select "Show Toolbar" from the dropdown.
    or
    Select "Customize Toolbar from the dropdown.
    When the Customize Toolbar sheet drops down, drag  "Send" button
    or  drag "default set" into the toolbar.
    Click "Done".

  • When I click on a link, multiple(and by multiple, I mean a ton) blank tabs open. The only way to stop more blank tabs from opening is to close out of firefox completely. Do I have a virus or do I need to change my settings?

    If I click on something to open in a new tab or click on someone's email to open Outlook, instead of doing that, a bunch of blank tabs open. I'm fine with a couple blank tabs, but they keep opening. The only way to stop the tabs from opening is to close out of firefox entirely. When I try to reopen firefox, blank tabs again begin to reopen. You can't close out of them fast enough because they keep opening. To stop opening the blank tabs, you must restart firefox a second time.
    Is this a virus or something wrong with my firefox settings??

    Firefox includes options of how to handle different content types, in your case the mailto links are probably set to "Use Firefox". For details of how to fix this see [[Firefox keeps opening many tabs or windows]], in particular the section "Change the action for a content type".

  • HT204053 the only way to creat an icloud account is with a ipad, iphone or imac. is it possible to creat the account from my windos PC? i already downladed i cloud, and i have an Apple ID but Not an Icloud account/

    the only way to creat an icloud account is with a ipad, iphone or imac. is it possible to creat the account from my windos PC? i already downladed i cloud, and i have an Apple ID but Not an Icloud account/

    Isa Garduño wrote:
    the only way to creat an icloud account is with a ipad, iphone or imac Apple computer.
    As you already knew, no, you cannot create a new iCloud account from anything but the above devices.
    http://support.apple.com/kb/HT4436

  • Hi ive upgraded my itouch to ios 6.1.3 but it keeps crashing ounce i put my passcode in is there a way i can fix this? one of my  friends mentioed downgrading it but the only way isnt supported by apple so i dont feel safe with it so plzz help me

    hi ive upgraded my itouch to ios 6.1.3 but it keeps crashing ounce i put my passcode in is there a way i can fix this? one of my  friends mentioed downgrading it but the only way isnt supported by apple so i dont feel safe with it so plzz help me.
    it has worked fine no problems till i updated it i tried restoring itwith my old backup but it doesnt move the ios back so it just keeps on craching when i try to unlock it

    Try:
    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Restore from backup. See:                                 
    iOS: How to back up           
    - Restore to factory settings/new iOS device.
    If still problem, make an appointment at the Genius Bar of an Apple store since it appears you have a hardware problem.
    Apple Retail Store - Genius Bar          
    Downgrading the iOS is not supported by Apple

  • HT1711 I have over 100 songs I bought back before mid-2009 when Apple dropped this DRM thing. If I want to play those songs on Sonos, the ONLY way to do so is pay Apple another $25/year for iTunes Match and re-download them??

    I have a Sonos system in my house and suddenly discovered that many songs I bought off of iTunes years ago are 'grayed out' when I try to play them from my iPhone or do not appear as options at all when I try to play them on Sonos from my overall music library.  It's well over 100 songs I bought back before mid-2009 when Apple dropped this DRM thing. From what I think I am reading, if I want to play those songs on Sonos, the ONLY way to do so is pay Apple another $25/year for iTunes Match (which I don't have any interest in) and then re-download them all in iTunes Plus format??

    Matt, 
    I agree it was not all communicated real well, but in your case it will work out.  You missed the program where you could have upgraded 100 tracks for 30 cents each (=$30) but now you can do it via Match (=$25).  It works pretty simply, per this document:
    Can I upgrade my previously purchased music to iTunes Plus?
    Yes. If you subscribe to iTunes Match, you can download your previously purchased music again in the iTunes Plus format. To do so:
    You need to delete the original DRM song from your library first. Doing this enables you to download the song again in the iTunes Plus format from iTunes in the Cloud.
    Click the Purchased tab in the iTunes Store.
    Click Music.
    Locate the artist of the song you want to upgrade.
    Click the iCloud Download icon next to the song you want to upgrade.
    Just don't forget to put the Plus files on your hard drive -- properly backed up of course -- and to cancel the Match subscription before the second year rolls around!

  • When I import photos taken from my Ipod Touch 4 to My Mac Desktop, I click delete photos on ipod, but they do not delete. Is the only way to delete them individually (I have 1,400 photos!) or is there a way to delete them all in one go?

    When I import photos taken from my Ipod Touch 4 to My Mac Desktop, I click delete photos on ipod, but they do not delete. Is the only way to delete them individually (I have 1,400 photos!) or is there a way to delete them all in one go?
    I realise you can you can delete them on your ipod slowly as you have to click on each one, and you can restore your ipod, but surely there is a way to get around this?
    Software: 4.3.2
    Build Version: 8H7
    Thanks If anyone can help me.

    Download/install an app is a know possible solution.
    3. Install another app from the App Store
    If all user-installed apps are not launching, it could be an Apple ID authorization issue. Download and install an app that isn't already installed on your device to reset this information.
    Note: If you have installed apps using multiple Apple ID accounts, you may need to perform this step for each account.
    Above from Apple's :
    iOS: Troubleshooting applications purchased from the App Store

  • I wish to upgrade my Macbook Pro to ML from SL but told the only way to do this is by downloading thru App store. Is it possible to copy ML on a USB and upgrade that way. I would like to have a back up of the OS just in case i have a problem later. Help!

    I wish to upgrade my Macbook Pro to ML from SL but told the only way to do this is by downloading thru App store. Is it possible to copy ML on to a USB and upgrade that way. I would like to have a back up of the OS installation files just in case i have a problem later. Please help me!

    You can create an install disc but you would have to download Mountain Lion to do so..
    How to create an OS X 10.8 Mountain Lion install drive | MacFixIt - CNET Reviews
    And make sure your Mac can upgrade to Mountain Lion.
    See Step 1, 2, and 3, here >  Apple - Upgrade your Mac to OS X Mountain Lion.

Maybe you are looking for