You must call myThread.start(), not myThread.run(). Calling run()
directly will not executed the code in the thread.
On Mon, May 5, 2008 at 10:39 AM, Hielko <[EMAIL PROTECTED]> wrote:
>
> what happends when you put an infinite loop inside your thread?
>
> On 5 mei, 19:33, 6real <[EMAIL PROTECTED]> wrote:
>> Dear all,
>>
>> I don't understand the behavior of the Activity and thread process.
>>
>> What I would like to do :
>> I open a map activity but there are several process. I would like to
>> open the map center on a point, start the process and finally center
>> and span the map.
>>
>> What I have done (look a t the debug with STEP inside):
>>
>> public class MyMapActivity extends MapActivity implements
>> OnClickListener, Runnable {
>>
>> public void onCreate(Bundle icicle) {
>> super.onCreate(icicle);
>> Log.d("MAP", "STEP ON CREATE 1");
>>
>> setContentView(R.layout.map_main);
>>
>> Thread threadOfMap = new Thread(this);
>> threadOfMap.run();
>> Log.d("MAP", "STEP ON CREATE 2");
>> }
>>
>> public void run() {
>> Log.d("MAP", "STEP RUN 1");
>>
>> //a long process than can be mocked by a sleep :
>> try{
>> Thread.sleep(3000);
>>
>> }catch (Exeption e){
>> }
>>
>> Log.d("MAP", "STEP RUN 2");
>> }
>>
>> }
>>
>> What I expect (interms of order of logs : )
>> DEBUG/MAP(1146): STEP ONCREATE 1
>> DEBUG/MAP(1146): STEP RUN 1
>> DEBUG/MAP(1146): STEP ONCREATE 2
>> DEBUG/MAP(1146): STEP RUN 2
>>
>> What I obtain
>> DEBUG/MAP(1146): STEP ONCREATE 1
>> DEBUG/MAP(1146): STEP RUN 1
>> DEBUG/MAP(1146): STEP RUN 2
>> DEBUG/MAP(1146): STEP ONCREATE 2
>>
>> ----------------
>> It seems that my applications waits for the run method to be finished,
>> on the onCreate. If I call the run method, I expect the run to be
>> launched in a separate process...
>>
>> ---------------
>>
>> I think the issu comes from my understanding of threads, if someone
>> can give me hints ?
>>
>> Thx !
> >
>
--
Romain Guy
www.curious-creature.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---