I don't seem to able to get a Thread to be garbage collected. Below is
the source code (modified from HelloAndroid). I put a break point in
the finalize function and it never seems to get called. If I remove
"extends Thread" from the TestThread definition then the finalize
function gets called as expected. What's going on?

package com.example.helloandroid;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class HelloAndroid extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        TextView tv = new TextView(this);
        tv.setText("Hello, Android");
        setContentView(tv);

        TestThread t = new TestThread();
        t = null;
        System.gc();
    }

    class TestThread extends Thread {
        protected void finalize() throws Throwable {
                super.finalize();
        }
    }
}


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to