java - new Thread(runnable, name) return null -


i have problem multi-threaded application, bound button stop thread

thread = null; 

after start thread (using same variable)

thread = new thread(this, "game"); thread.start(); 

after new thread, thread still null , don't know why please help.

without more information following speculation. please in future show more details , explain have done debug problem.

after new thread, thread still null , don't know why please help.

it not possible constructor return null else going on.

thread thread = null; thread = new thread(this, "game"); // thread guaranteed non-null here 

maybe sharing thread field between 2 threads? example, maybe main thread starts background thread , ui thread trying read it? in case should make thread volatile shared between threads.

volatile thread thread = null; 

if volatile you dealing different instance of thread field. maybe thread field should marked static?


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -