I am writing an Android application and use workflows to process certain information. After reading my code, I am now not sure how safe the stream is.
I wrote a simplified version of my code, I omitted the Handler object used to communicate with the main thread and, obviously, with the process itself.
public class myClass implements Runnable { private String myString; @Override public void run() { myString = "Some Value"; } }
This is caused by the launch of something similar to this.
myClass class = new myClass(); Thread thread = new Thread(class); thread.start()
So, this code is not thread safe because I am changing myString (declared in the main thread) in the run() function?
android multithreading runnable thread-safety
Leo
source share