BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 02-20-2009, 04:49 PM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: Jan 2009
Model: 7100T
PIN: N/A
Carrier: -
Posts: 73
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default why i cannot pause timer

Please Login to Remove!

hi,

i've got such a problem:i use timer.scheduledAtFixedRate in another thread. the problem is, that when some action happens, i must pause this timer, and when another action happens i must resume it. it looks more or less like this:


PHP Code:
public void run(){

if( 
something1 )

{

timer.scheduleAtFixedRate(TimerTasktime1time2);

}

if(
something2){

synchronized(timer){

timer.wait();

}
}

if(
something3){

timer.notify();

}


the problem is-that i cannot pause it! wait() method just does not work and i do not know why.. the only thing that works is cancel() method. but i do not want to cancel my timer i need to pause it until 'something3' happens..



Can You please suggest me anything?


ps. i also tried to use a flag, smth like this:


PHP Code:
public void run(){

boolean flag true;

if( 
something1 && flag == true)

{

timer.scheduleAtFixedRate(TimerTasktime1time2);

}


if(
something2){

flag false;

}

if(
something3){

flag true;
}


but this also did not pause (even did not stop!) my timer...


i'll be gratefull for any suggestions..


regards
Offline  




Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.