Skip to content

Commit

Permalink
docs: simplify multitask demo and add java file
Browse files Browse the repository at this point in the history
  • Loading branch information
Eddie authored and Eddie committed Jun 3, 2024
1 parent 9bb10a5 commit 8c6a3c2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 34 deletions.
39 changes: 5 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,44 +168,15 @@ Ensure the class for `multitask`:
- compiled with the `JUNGLEPATH` environment variable with the classpath

```shell
# Create a folder for out program example.
mkdir -p /tmp/demo/com/example
# Compile the Java class used by our program
javac programs/com/example/MultitaskRunnable.java

# Write a Runnable Java class
echo '
package com.example;
public class MultitaskRunnable implements Runnable {
@Override
public void run() {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
System.out.println(", world!");
}
}
' > /tmp/demo/com/example/MultitaskRunnable.java

# Compile the Java class
javac /tmp/demo/com/example/MultitaskRunnable.java
```

```shell
# Declare the classpath before compiling,
# Declare the classpath before compiling or running,
# so that our Runnable class can be validated
export JUNGLEPATH=".:/tmp/demo"
export JUNGLEPATH='.:./programs'

# Compile and run the program
echo '
multitask "com.example.MultitaskRunnable"
print "Hello"
' | jungle scan \
| jungle parse \
| jungle compile --output Demo

java -classpath $JUNGLEPATH Demo
cat programs/multitask.source | jungle run
```

Expected output:
Expand Down
13 changes: 13 additions & 0 deletions programs/com/example/MultitaskRunnable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.example;

public class MultitaskRunnable implements Runnable {
@Override
public void run() {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
System.out.println(", world!");
}
}

0 comments on commit 8c6a3c2

Please sign in to comment.