01: /*
02: * @(#)ThreadAdapter.java 1.4 05/04/04
03: *
04: * Copyright (c) 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
05: *
06: * See the file "LICENSE.txt" for information on usage and redistribution
07: * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
08: */
09: package pnuts.multithread;
10:
11: import pnuts.lang.PnutsFunction;
12: import pnuts.lang.Context;
13: import pnuts.lang.Escape;
14:
15: /**
16: * An adapter class between PnutsFunction and Runnable
17: */
18: public class ThreadAdapter implements Runnable {
19: PnutsFunction func;
20: Context context;
21:
22: public ThreadAdapter(PnutsFunction func) {
23: this (func, new Context());
24: }
25:
26: public ThreadAdapter(PnutsFunction func, Context context) {
27: this .func = func;
28: this .context = context;
29: }
30:
31: public void run() {
32: try {
33: func.call(new Object[] {}, new Context(context));
34: } catch (Escape e) {
35: // skip
36: }
37: }
38: }
|