Trying to execute a method for a set time

Hi all,
Propably this is easy for most of you.
How can I try to excecute a method for a set amount of time before giving up.
For example with the URL
Try to open a connection to this URL
If we can not get a connection going within the time limit eg. 5 seconds
abort trying to connect
Thanks Oscar

long millisToTry = 5000;
long startedTrying = System.currentTimeMillis();
boolean connected = false;
while (!connected && (System.currentTimeMillis() - startedTrying < millisToTry))
    System.out.println("Trying...");
    // do your voodoo
    try{ Thread.sleep(1000); } catch (Exception e) {} // try once per second...
}

Similar Messages

  • Trying to install creative cloud for the first time and getting error code:1

    im trying to install creative cloud for the first time but im getting a error code:1
    what can I do?

    Creative Cloud Error Codes (WIP) | Mylenium's Error Code Database
    Mylenium

  • Trying to use laf project for the first time

    hi all , i need help , please
    i am trying to use laf project for the first time as i said , and i want help on
    the installation process
    step by step please , i am soo junior here
    i've just downloaded the zip file as the site said (http://fdtool.free.fr/LAF/doc/implementation.htm)
    please go to this url and declare the steps to me
    thanks in advance

    The Forms Look and Feel Project is not an Oracle product. This product was developed by Francois Degrelle. Francois has posted numerous times in this forum that if you need help with the LAF you have to go to the Oracle Forms Look & Feel Project web site or his PJCs and Java Beans Forum for support.
    Craig...

  • I live in Italy and I am trying to buy an App, for the first time with my iphone4...in the past only downloaded free apps free apps; I have a US Visa card and it is not accepted by italian Itunes...what can I do to do my purchases?

    I live in Italy and I am trying to buy an App, for the first time with my iphone4...in the past only downloaded free apps free apps; I have a US Visa card and it is not accepted by italian Itunes...what can I do to do my purchases?

    On the apple website that is correct i beleive.... but i have an italian american express and am able to purchase stuff here in the US.
    I mean, i dont think it really matters

  • How do you suppress page numbers. I am trying to print a screenplay for the first time since switching to Pages and I can't suppress Page

    How do you suppress page numbers. I am trying to print a screenplay for the first time since switching to Pages and I can't suppress Page #1 without making the rest of the pages inaccurate, as page #1 is the Title Page. Does anyone have any suggestions?

    When you signed to be able to post in the forums, you were urged to read and accept the Terms of Use ruling these forums.
    They claim :
    The contents of the "More Like This" box prove that applying the rules you would have get the wanted explanations without creating this new thread.
    Yvan KOENIG (VALLAURIS, France) mardi 26 avril 2011 10:04:03

  • I have tried to download the update for itunes several times and it will not complete, i get an error message

    I have tried to download the update for itunes several times. Each time it get to the installation part and stall and then reverses and give me an erorr message. My current version when I open it, it says there is an error and I will not be able to download a CD into itunes, although I have completed several CD downloads.

    Go to http://www.mozilla.org/en-US/firefox/new/ and download the full installer. Run the installer and you will be up-to-date. Sometimes the updater just gets in a weird state...

  • How can I execute a method on a specified time?

    How can I execute a method on a specified time such as method1() will be executed on 1:00 p.m and the method2() will be executed in 1:00 a.m?

    BilgeTonyukuk99 wrote:
    How can I execute a method on a specified time such as method1() will be executed on 1:00 p.m and the method2() will be executed in 1:00 a.m?As a simple example, take a look at http://www.javapractices.com/topic/TopicAction.do?Id=54.
    As an alternative (and looks like better approach), you could use the ScheduledThreadPoolExecutor.

  • I tried to sync my phone for the first time and it restored and now I have lost all my data.  It there any thing I can do?

    I tried to sync my phone for the first time and somehow it restored and i lost all my data.  Help!

    If you don't have a backup made by iTunes, your data and settings are gone.
    Apps and other media can be downloaded again for free:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store

  • Been trying to update my java for a long time now and i cannot figure it out. OS 10.6.8. Any help would be greatly appreciated

    Been trying to update my java for a long time now and i cannot figure it out. Have downloaded and installed it couple of times. Help would be greatly appreciated.

    http://support.apple.com/kb/DL1360

  • I am trying to logon to icloud for the 1st time on my pc, everything is setup, but it comes up with 'you cant sign in because of server error'

    I am trying to logon to icloud for the 1st time on my pc, everything is setup, but it comes up with 'you cant sign in because of server error'

    Hi tracey,
    It sounds like you are having issues with connecting to the iCloud servers, a frustrating situation to be sure. I would suggest troubleshooting using the steps in this article -
    iCloud: Account troubleshooting
    http://support.apple.com/kb/TS3988
    Thanks for using Apple Support Communities.
    Best,
    Brett L

  • TS1398 I am trying to install my ipad for the first time. I can't get it to recognise my password to my o2 server. What do I do?

    I am trying to install my ipad for the first time.  How do I know what password to use for my server?

    Only you or the person responsible for the server knows.
    What do you mean by server?
    BTW, you posted in the iPod touch forum.

  • Why UPD processes execute report RSM13000 for very long time?

    Hi,
    When I use sm50 or sm51 to check my CRM system which version is 5.0, I found some UPD processes execute report RSM13000 for very long time. And some DIA processes are executing report SAPMSSY1 for verly long time too. They are occupy lot of processes of system. How does this happen? What's the reason and how to solve it? Thanks for your help!
    Many thanks and Best regards,
    Long

    Please check the configurtion of your system.As per your reply it seems that the work processes are not sufficient in the system.
    Hi wait time and response time  ,is  problem in the system.Either you have a lot of load on the system or you CPU's are over loaded.
    Please check the system status from st06 and look for the cpu utilisation /memory utilisation.
    SM66 to see the long running online and background jobs.
    St03n - look for the workload and wait times for all transactions.
    st02-may help in checking the memory paramaetrs.
    Hope it will help you in resolving the issue.
    Thanks
    Amit

  • When trying to launch my mail for the 1st time on apple 4s, mail error MFMessageErrorDomain error 1032

    when trying to launch my mail for the 1st time on apple 4s, mail error MFMessageErrorDomain error 1032 happenes

    https://discussions.apple.com/thread/4772709?start=0&tstart=0

  • Error when tried to execute ODI interface for Essbase

    Hi,
    I am trying to load metadata from a file to Essbase. Bur when i am trying to execute the interface, i am getting an error. It reads as follows
    Cannot start execution
    The sourcedatatype is null for the column : ParentName and the technology: Hyperion essbase.

    Hi John,
    I have gone ahead and deleted the Hyperion essbase technology and imported it similar to Hyperion Planning. Now i am able to see only 3 datatypes. Date, String and Numeric.
    I have setup all the connections and created the interface also.
    But when i executed it i got the following error
    org.apache.bsf.BSFException: exception from Jython: Traceback (innermost last):
    File "<string>", line 35, in ?
    AttributeError: class 'com.hyperion.odi.common.ODIConstants' has no attribute 'READER_TYPE'
         at org.apache.bsf.engines.jython.JythonEngine.exec(Unknown Source)
         at com.sunopsis.dwg.codeinterpretor.k.a(k.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.scripting(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execScriptingOrders(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execScriptingOrders(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSqlC.treatTaskTrt(SnpSessTaskSqlC.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java)
         at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java)
         at com.sunopsis.dwg.cmd.DwgCommandSession.treatCommand(DwgCommandSession.java)
         at com.sunopsis.dwg.cmd.DwgCommandBase.execute(DwgCommandBase.java)
         at com.sunopsis.dwg.cmd.e.i(e.java)
         at com.sunopsis.dwg.cmd.g.y(g.java)
         at com.sunopsis.dwg.cmd.e.run(e.java)
         at java.lang.Thread.run(Thread.java:595)
    What is the mistake i have done. Please let me know

  • Trying to purchase on iTunes for the first time on new Mac, asking for verifying questions-saying answers are incorrect. Reset password,still won't allow purchase without answering questions. Any advice?

    Trying to purchase on itunes, using new Mac...asking for security questions but won't accept answers. reset password and iTunes still asks for security questions. Any advice?

    After resetting your questions you've tried logging out (tap on your id in Settings > iTunes & App Store) and back into your account on your iPad to see if they then tie up ?
    If they don't, and resetting them yourself doesn't make any difference, then you could try contacting Support and see if they can help with what's going on.
    Normally when needing to contact support to get the questions reset you need to contact Support in your country : http://support.apple.com/kb/HT5699
    You could try the same contact method for your problem - or you could try contacting iTunes Support via this page, but as it's related to security questions they might just point you to the above : http://www.apple.com/support/itunes/contact/ , click on Contact iTunes Store Support on the right-hand side of the page
    For the $9.99 purchase and your $10 credit, if you are in the US then you need to add on your state's sales tax to an item's listed price

Maybe you are looking for

  • Report on Contract qty vs. PO Qty

    Good Morning! I am in need of getting a report out of SAP that shows the original contract qty and the revised qty of the contract.  My client at times may change the contract in order to create the PO for a larger qty than the original contract stat

  • Changing the Column name of a table horizontally

    Hi , I have a table named emp. Empno Sal 10 1000 20 2000 30 3000 40 4000 I need the output like Empno 10 20 30 40 sal 1000 2000 3000 4000 Note: It should work for any table. Also not the column & row mapping which should be synchronised like the orig

  • How to search for apps that will run on os 4.2

    How do ytou search for apps and things that will run on the older OS 4.2.1??????????

  • How to export counter to rtsi?

    I am generating a counter frequency out signal on a pci-6220 m-series card.  I want to then share this signal with other cards over an RTSI line, and therefore, I use export signal VI.  However, right after a computer reboot this VI will not produce

  • Now a few of programs does not work with mountian lion. what to do?

    now a few of programs does not work with mountian lion. what to do?