Forums Register Login

threading in j2me

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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:

+Pie Number of slices to send: Send
hi,
thnx man...ill try that right away.
arvind
joke time: What is brown and sticky? ... ... ... A stick! Use it to beat this tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 836 times.
Similar Threads
check my code please?
Exception in thread "main"
Struts 2 + Credit Card Validation
Credit Card Verification
unpaid itinerary
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 19, 2024 05:17:51.