File tree Expand file tree Collapse file tree
library/src/main/java/com/proxerme/library/connection Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -75,8 +75,8 @@ public String id() {
7575 }
7676 };
7777
78- private static Handler handler = new Handler (Looper .getMainLooper ());
79- private static ConcurrentLinkedQueue <ParseThread > parseThreads = new ConcurrentLinkedQueue <>();
78+ private static final Handler handler = new Handler (Looper .getMainLooper ());
79+ private static final ConcurrentLinkedQueue <ParseThread > parseThreads = new ConcurrentLinkedQueue <>();
8080
8181 /**
8282 * Entry point to load News of a specified page.
@@ -132,18 +132,20 @@ public static ConferencesRequest loadConferences(@IntRange(from = 1) int page) {
132132 * @see ProxerTag
133133 */
134134 public static void cancel (@ ConnectionTag int tag ) {
135- Iterator <ParseThread > iterator = parseThreads .iterator ();
135+ synchronized (parseThreads ) {
136+ Iterator <ParseThread > iterator = parseThreads .iterator ();
136137
137- while (iterator .hasNext ()) {
138- ParseThread current = iterator .next ();
138+ while (iterator .hasNext ()) {
139+ ParseThread current = iterator .next ();
139140
140- if (current .getTag () == tag ) {
141- current .interrupt ();
142- iterator .remove ();
141+ if (current .getTag () == tag ) {
142+ current .interrupt ();
143+ iterator .remove ();
144+ }
143145 }
144- }
145146
146- Bridge .cancelAll ().tag (String .valueOf (tag )).commit ();
147+ Bridge .cancelAll ().tag (String .valueOf (tag )).commit ();
148+ }
147149 }
148150
149151 /**
You can’t perform that action at this time.
0 commit comments