![](/img/trans.png)
[英]problem with joda new DateTime(int,int,int,int,int,int)
[英]int set to zero generates new int by the same name tho
當我創建一個使用以下函數遞增的int COun
,一旦將其設置為所需的int並將其設置回零,該COun
被設置為零,並再次開始遞增直到10,但它會遞增另一個int,其名稱與我假設的相同。 為什么這樣做呢?
Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask()
{
public void run()
{
// Your code
counterr++;
System.out.println("COun "+counterr);
// System.out.println("Refresh? "+refresh);
if(counterr>10){
json = jParser.makeHttpRequest(url_all_products, "GET", params);
Intent i = new Intent(getApplicationContext(), AllProductsActivity.class);
startActivity(i);
counterr=0;
}
}
}, delay, period);
當您打印出COun時,可以說只是增加一個COun而已,但是每當句子出現時,它都會生成另一個COun計數器。
12-20 18:50:16.170: I/System.out(10465): COun 1
12-20 18:50:17.071: I/System.out(10465): COun 2
12-20 18:50:18.082: I/System.out(10465): COun 3
12-20 18:50:19.083: I/System.out(10465): COun 4
12-20 18:50:20.084: I/System.out(10465): COun 5
12-20 18:50:21.085: I/System.out(10465): COun 6
12-20 18:50:22.086: I/System.out(10465): COun 7
12-20 18:50:23.077: I/System.out(10465): COun 8
12-20 18:50:24.078: I/System.out(10465): COun 9
12-20 18:50:25.079: I/System.out(10465): COun 10
12-20 18:50:26.080: I/System.out(10465): COun 11
12-20 18:50:27.071: I/System.out(10465): COun 1
12-20 18:50:28.082: I/System.out(10465): COun 2
12-20 18:50:29.073: I/System.out(10465): COun 3
12-20 18:50:30.083: I/System.out(10465): COun 4
12-20 18:50:31.084: I/System.out(10465): COun 5
12-20 18:50:31.405: I/System.out(10465): COun 1
12-20 18:50:32.085: I/System.out(10465): COun 6
12-20 18:50:32.406: I/System.out(10465): COun 2
12-20 18:50:33.086: I/System.out(10465): COun 7
12-20 18:50:33.407: I/System.out(10465): COun 3
12-20 18:50:33.407: I/System.out(10465): COun 8
12-20 18:50:33.407: I/System.out(10465): COun 4
12-20 18:50:33.407: I/System.out(10465): COun 9
12-20 18:50:33.407: I/System.out(10465): COun 5
然后像這樣怪異地繼續下去,當其中一個變成10時,它會生成另一個與原始數一起計數的計數,然后不斷地……
如果要執行一次,則應致電
schedule(TimerTask task,Date time)
要么
schedule(TimerTask task, long delay)
scheduleAtFixedRate(TimerTask task,long delay,long period)
是需要重復運行的時間。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.