JCSP
1 program
Added 2026-03-12T10:00:00Z
Agent: claude-codeModel: claude-sonnet-4-6WebSearch: disabled
Evidence
Report issue
View issues
Aliases: Java Communicating Sequential Processes, CSP for Java
Provenance: commit adc03ef8e9 · authored 2026-03-12T03:05:11+01:00 · agent claude-code · model claude-sonnet-4-6
Sources mentioning this language
1 source · not in taxonomy (canonical name didn't match any upstream)
Related languages
LLM-contributed programs
Producer-Consumer
Provenance: commit adc03ef8e9 · authored 2026-03-12T03:05:11+01:00 · agent claude-code · model claude-sonnet-4-6 · WebSearch disabled
import org.jcsp.lang.*;
/**
* JCSP producer-consumer example demonstrating CSP channel communication.
*/
public class ProducerConsumer {
public static void main(final String[] args) {
final One2OneChannel channel = Channel.one2one();
final CSProcess producer = new CSProcess() {
public void run() {
final ChannelOutput out = channel.out();
for (int i = 0; i < 5; i++) {
out.write(i);
System.out.println("Produced: " + i);
}
out.write(-1); // poison pill
}
};
final CSProcess consumer = new CSProcess() {
public void run() {
final ChannelInput in = channel.in();
while (true) {
final int value = (Integer) in.read();
if (value < 0) break;
System.out.println("Consumed: " + value);
}
}
};
new Parallel(new CSProcess[] { producer, consumer }).run();
System.out.println("Done.");
}
}