提交 47c722c8 编写于 作者: oldratlee's avatar oldratlee 🔥

update readme

上级 86f779e3
......@@ -7,7 +7,10 @@ multi-thread context(MTC)
<a href="https://github.com/alibaba/multi-thread-context/blob/master/README.md">中文文档</a>
</div>
Transmit multi-thread context, even using thread cached components like thread pool.
:wrench: Functions
----------------------------
:point_right: Transmit multi-thread context, even using thread cached components like thread pool.
Class [`java.lang.InheritableThreadLocal`](http://docs.oracle.com/javase/6/docs/api/java/lang/InheritableThreadLocal.html) in `JDK`
can transmit context to child thread from parent thread.
......@@ -23,7 +26,7 @@ If you have problem or question,
- Click "Options > Post by email..." to get the email address of this mailing list;
- You can post messages via email or through the forum interface.
Requirements
:art: Requirements
----------------------------
The Requirements listed below is also why I sort out `MTC` in my work.
......@@ -31,7 +34,7 @@ The Requirements listed below is also why I sort out `MTC` in my work.
* Application container or high layer framework transmit information to low layer sdk.
* Transmit context to logging without application code aware.
User Guide
:notebook: User Guide
=====================================
1. simple usage
......@@ -135,6 +138,23 @@ String value = parent.get();
### 2.3. Use Java Agent to decorate thread pool implementation class
In this usage, `MtContext` transmission is transparent\(no decoration operation\).
Sample code:
```java
ExecutorService executorService = Executors.newFixedThreadPool(3);
Runnable task = new Task("1");
Callable call = new Call("2");
executorService.submit(task);
executorService.submit(call);
// =====================================================
// Task或是Call中可以读取, 值是"value-set-in-parent"
String value = parent.get();
```
See demo [`AgentDemo.java`](https://github.com/alibaba/multi-thread-context/blob/master/src/test/java/com/alibaba/mtc/threadpool/agent/AgentDemo.java).
Agent decorate 2 thread pool implementation classes
......@@ -143,7 +163,7 @@ Agent decorate 2 thread pool implementation classes
- `java.util.concurrent.ThreadPoolExecutor`
- `java.util.concurrent.ScheduledThreadPoolExecutor`
Add start argumetns on Java:
Add start options on Java command:
- `-Xbootclasspath/a:/path/to/multithread.context-x.y.z.jar:/path/to/javassist-3.12.1.GA.jar`
- `-javaagent:/path/to/multithread.context-x.y.z.jar`
......@@ -165,12 +185,12 @@ java -Xbootclasspath/a:dependency/javassist-3.12.1.GA.jar:multithread.context-1.
Run the script [`run-agent-demo.sh`](https://github.com/alibaba/multi-thread-context/blob/master/run-agent-demo.sh)
to start demo of "Use Java Agent to decorate thread pool implementation class".
Java API Docs
:electric_plug: Java API Docs
======================
The current version Java API documentation: <http://alibaba.github.io/multi-thread-context/apidocs/>
Maven dependency
:cookie: Maven dependency
=====================================
```xml
......@@ -183,11 +203,24 @@ Maven dependency
Check available version at [search.maven.org](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22multithread.context%22%20g%3A%22com.alibaba%22).
Related resources
:books: Related resources
=====================================
Jdk core classes
----------------------------
* [WeakHashMap](http://docs.oracle.com/javase/7/docs/api/java/util/WeakHashMap.html)
* [InheritableThreadLocal](http://docs.oracle.com/javase/7/docs/api/java/lang/InheritableThreadLocal.html)
Java Agent
----------------------------
* [Java Agent规范](http://docs.oracle.com/javase/6/docs/api/java/lang/instrument/package-summary.html)
* [Java SE 6 新特性: Instrumentation 新功能](http://www.ibm.com/developerworks/cn/java/j-lo-jse61/)
* [Creation, dynamic loading and instrumentation with javaagents](http://dhruba.name/2010/02/07/creation-dynamic-loading-and-instrumentation-with-javaagents/)
* [JavaAgent加载机制分析](http://alipaymiddleware.com/jvm/javaagent%E5%8A%A0%E8%BD%BD%E6%9C%BA%E5%88%B6%E5%88%86%E6%9E%90/)
Javassist
----------------------------
* [Getting Started with Javassist](http://www.csg.ci.i.u-tokyo.ac.jp/~chiba/javassist/tutorial/tutorial.html)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册