• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

is it possible to check which thread is currently executing?

 
Joel Karimpil
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

is it possible to check which thread is currently executing in MIDP?
actually i want to display a gauge for connection and download status and i
want to increment the gauge as per data download...
i already have implemented the Runnable interface..
now using another thread i need to increment the gauge value until a boolean
variable returns true.
but for this, i need to check which thread is executing ....
plz help.
 
martin filton
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe you can use the static metode currentThread() and then compare it to the one you are using?

-Martin
 
Tomas Conway
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm asuming that you are using a seperate thread for displaying the gauge, and that your runnable method is in a class created specifically for this purpose.

Why would you need to know which thread is executing?

You could add a method (say setLevel()) to your gauge thread class that sets a variable corresponding to the gauge level. Your run() method can adjust the gauge according to the value of your this variable.

In your main thread you'll start the gauge thread. You can monitor the data from the main thread, and call setLevel() (you'll have a reference to the gauge thread of couse) whenever you need to. The gauge thread's run() method will pick up on the changes and adjust the gauge accordingly. If your boolean variable is in your gauge thread class you can just check this it's value using your gauge thread class reference.

[ December 01, 2004: Message edited by: Tomas Conway ]
[ December 01, 2004: Message edited by: Tomas Conway ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic