Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

How to sleep
 Post subject: How to sleep Post rating: 0   New post Posted: Tue 31 Mar, 2009, 07:28 

User rating: 0
Joined: Tue 31 Mar, 2009, 07:19
Posts: 4
I want to let my strategy to sleep, i.e. idle for a certain time in its thread.
How can I do it?
Thanks.


 
 Post subject: Re: How to sleep Post rating: 0   New post Posted: Tue 31 Mar, 2009, 14:01 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Java docs: https://java.sun.com/javase/6/docs/api/java/lang/Thread.html#sleep(long)

try {
    Thread.sleep(1000);
  } catch (InterruptedException e) {
    e.printStackTrace();
    // handle the exceptional condition properly
}


Where 1000 means 1000 milliseconds, so if you want your thread to sleep for one second use 1000


 
 Post subject: Re: How to sleep Post rating: 0   New post Posted: Sat 11 Feb, 2017, 17:08 

User rating: 0
Joined: Fri 31 May, 2013, 21:20
Posts: 14
Location: Syrian Arab RepublicSyrian Arab Republic
HI

when I try to use SLEEP for about 10 second in any IF CONDITION, will the whole strategy Freeze for that period of time
Or it will continue the other calculatios and when the sleep period is over it will recaluclate that IF CONDTION ?


 
 Post subject: Re: How to sleep Post rating: 0   New post Posted: Mon 13 Feb, 2017, 08:15 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
All methods of IStrategy are called in the same thread. Therefore, the strategy will stop all other work until 10 seconds pass.
We should note that each strategy instance has a separate thread and other strategies will continue executing.


 
 Post subject: Re: How to sleep Post rating: 0   New post Posted: Sat 25 Mar, 2017, 03:04 
User avatar

User rating: 0
Joined: Sat 18 Mar, 2017, 05:03
Posts: 26
Location: China,
Do nothing and return is enough.


 

Jump to:  

cron
  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com