Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

threading in j2me

 
arvind doraiswamy
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
I'm facing a slight problem here .I'm making a mini banking application using j2me.Now i added features for a person to check his credit card balance ,banking , shopping and sharetrading.Now the creditcard is working fine.But the problem is i'm using threads so if i declare a new thread in the command action and start it (for credit card) it automatically goes to public void run() like it does normally.Now if i want to select another option;say banking i need to define a new thread whoch obviously functions differently .How do i get that thread to automatically go to its public void run()...and i can have only 1 method as run()...right??...will i have to write this code in a separate midlet?...if not how to do it?
Thanks
Arvind
 
Alan Walker
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This can be done using the same multithreading techniques as in any version of Java.

You can have as many different run() methods as you need, but each one has to be defined within its own runnable class.

(How many of these run() methods can actually run at the same time with acceptable speed depends on the processing power of the device of course).

You can do this with anonymous inner classes that implement the Runnable interface. Or simply with an anonymous class that extends the Thread class, since Thread implements Runnable. So you can have code like this:

 
arvind doraiswamy
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
thnx man...ill try that right away.
arvind
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic