From 7203dda7aab42d4ccdf608441444fa6558ef2463 Mon Sep 17 00:00:00 2001 From: serso Date: Mon, 14 Mar 2016 21:16:17 +0100 Subject: [PATCH] Fix racing condition between threads in Memory --- .../org/solovyev/android/calculator/memory/Memory.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/solovyev/android/calculator/memory/Memory.java b/app/src/main/java/org/solovyev/android/calculator/memory/Memory.java index 0f6aa8c1..9887d157 100644 --- a/app/src/main/java/org/solovyev/android/calculator/memory/Memory.java +++ b/app/src/main/java/org/solovyev/android/calculator/memory/Memory.java @@ -36,21 +36,22 @@ public class Memory { private final WriteTask writeTask = new WriteTask(); @NonNull private final Runnables whenLoadedRunnables = new Runnables(); + @NonNull + private final Handler handler; @Inject Notifier notifier; @Named(AppModule.THREAD_BACKGROUND) @Inject Executor backgroundThread; - @Inject - Handler handler; @NonNull private Generic value = EMPTY; private boolean loaded; @Inject - public Memory(@NonNull @Named(AppModule.THREAD_INIT) Executor initThread, @NonNull FileSystem fileSystem, @NonNull @Named(AppModule.DIR_FILES) File filesDir) { + public Memory(@NonNull @Named(AppModule.THREAD_INIT) Executor initThread, @NonNull FileSystem fileSystem, @NonNull @Named(AppModule.DIR_FILES) File filesDir, @NonNull Handler handler) { this.fileSystem = fileSystem; this.filesDir = filesDir; + this.handler = handler; initThread.execute(new Runnable() { @Override public void run() {