File tree Expand file tree Collapse file tree 1 file changed +52
-2
lines changed Expand file tree Collapse file tree 1 file changed +52
-2
lines changed Original file line number Diff line number Diff line change @@ -215,8 +215,58 @@ public static Object runScript(File jsFile) throws NativeScriptException
215
215
216
216
if (jsFile .exists () && jsFile .isFile ())
217
217
{
218
- String filePath = jsFile .getAbsolutePath ();
219
- result = runScript (filePath );
218
+ final String filePath = jsFile .getAbsolutePath ();
219
+
220
+ boolean isWorkThread = threadScheduler .getThread ().equals (Thread .currentThread ());
221
+
222
+ if (isWorkThread )
223
+ {
224
+ result = runScript (filePath );
225
+ }
226
+ else
227
+ {
228
+ final Object [] arr = new Object [2 ];
229
+
230
+ Runnable r = new Runnable ()
231
+ {
232
+ @ Override
233
+ public void run ()
234
+ {
235
+ synchronized (this )
236
+ {
237
+ try
238
+ {
239
+ arr [0 ] = runScript (filePath );
240
+ }
241
+ finally
242
+ {
243
+ this .notify ();
244
+ arr [1 ] = Boolean .TRUE ;
245
+ }
246
+ }
247
+ }
248
+ };
249
+
250
+ boolean success = threadScheduler .post (r );
251
+
252
+ if (success )
253
+ {
254
+ synchronized (r )
255
+ {
256
+ try
257
+ {
258
+ if (arr [1 ] == null )
259
+ {
260
+ r .wait ();
261
+ }
262
+ }
263
+ catch (InterruptedException e )
264
+ {
265
+ result = e ;
266
+ }
267
+ }
268
+ }
269
+ }
220
270
}
221
271
222
272
return result ;
You can’t perform that action at this time.
0 commit comments