Skip to content

Commit 28983b4

Browse files
committed
extending classes from javascript
1 parent 423b9d3 commit 28983b4

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

res/nashorn3.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,23 @@ list2
8585
.sorted()
8686
.forEach(function(el) {
8787
print(el);
88-
});
88+
});
89+
90+
91+
92+
print('------------------');
93+
print('Extend:');
94+
95+
var Runnable = Java.type('java.lang.Runnable');
96+
var Printer = Java.extend(Runnable, {
97+
run: function() {
98+
print('This was printed from a seperate thread.');
99+
}
100+
});
101+
102+
var Thread = Java.type('java.lang.Thread');
103+
new Thread(new Printer()).start();
104+
105+
new Thread(function() {
106+
print('this was printed from another thread');
107+
}).start();

0 commit comments

Comments
 (0)