cangjie-concurrency

Solve Cangjie concurrency challenges with M:N threading, Mutex, and Future.

4|1|Updated Mar 29, 2026
One-click install
npx skills add https://github.com/JunjieChen0/NJUST --skill cangjie-concurrency-junjiechen0
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cangjie-concurrency
Source: https://github.com/JunjieChen0/NJUST/tree/main/.njust-ai/skills/cangjie-concurrency
Command: npx skills add https://github.com/JunjieChen0/NJUST --skill cangjie-concurrency-junjiechen0

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Concurrency in Cangjie can be complex; this Skill helps developers learn and apply concurrent programming patterns, including M:N threading, thread creation with spawn, sleep, atomic operations, mutexes, condition variables, synchronized blocks, futures, and ThreadLocal storage.

Core Features & Use Cases

  • Thread creation and scheduling: spawn, sleep, and the M:N threading model.
  • Synchronization primitives: Atomic operations, Mutex, Condition, and synchronized blocks.
  • Coordination and lifecycle: Future, cancellation model, SyncCounter, and ThreadLocal storage for complex workflows.

Quick Start

Use spawn to create a simple thread and demonstrate safe synchronization with a mutex and a condition variable.

Frequently Asked Questions about cangjie-concurrency

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create and synchronize threads in Cangjie using spawn and Mutex?

To create and synchronize threads in Cangjie, use the spawn function to start a thread and a Mutex to ensure safe access to shared data. This approach prevents race conditions in concurrent workflows.

What is the M:N threading model in Cangjie and when should I use it?

The M:N threading model in Cangjie maps multiple user-level threads onto fewer kernel threads. Use this model to efficiently manage large numbers of concurrent tasks without excessive kernel overhead.

How do I use Future and Condition variables for thread coordination in Cangjie?

Use Future in Cangjie to handle asynchronous results and Condition variables to pause and resume threads based on shared state changes. Together they coordinate complex concurrent workflows and lifecycle management.

Can I perform atomic operations and use ThreadLocal storage in Cangjie?

Yes, Cangjie supports atomic operations for lock-free memory ordering and ThreadLocal storage to isolate per-thread data. These features ensure safe state management without explicit locking overhead.

What are the memory ordering and locking semantics for synchronized blocks in Cangjie?

Synchronized blocks in Cangjie enforce strict locking semantics to serialize access to critical sections. They establish memory ordering guarantees, ensuring thread-safe visibility of shared variables.

Does Cangjie support a cancellation model and SyncCounter for concurrent task lifecycle?

Yes, Cangjie provides a cancellation model to gracefully terminate concurrent tasks and a SyncCounter to coordinate thread completion. These primitives manage complex thread lifecycles and safe task termination.