
Tiger Thread
文章平均质量分 75
iteye_5554
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Java Thread programming basical knowledge
yield() : Give a hint to the thread scheduling mechanism that, you’ve done enough and some other thread might as well have the CPU. And this is really a hint --- there is no guarantee that your implem...原创 2009-02-26 22:40:03 · 142 阅读 · 0 评论 -
Delayed interface and Delay Queue
/** * A standard implementation for Delayed interface * * A Delayed instance means something which has a time attribute. Generally means a thread * will start up this time later. * ...原创 2009-04-22 17:42:49 · 110 阅读 · 0 评论 -
Count Down Latch example code
Key point : 1) 1 task is composed of several portion. 2) every portion finished, the portion will call latch.countDown() 3) Threads depending on this task will call latch.await() 4) la...原创 2009-04-22 10:38:14 · 107 阅读 · 0 评论 -
3 ways to break dead lock
1) supply special resources. This resource can be only used by one special thread. 2) permit held up resources can be required by other threads. threads manager should be able to signal ...原创 2009-04-21 17:30:48 · 109 阅读 · 0 评论 -
Blocking Queue Usage
3 implementations: LinkedBlockingQueue, ArrayBlockingQueue, SynchronousQueue, About threading communication, use wait()/notify()/notifyAll() is really quite low level. And it's error-prone, an...原创 2009-04-20 11:21:58 · 100 阅读 · 0 评论 -
The usage of Lock and Condition
//: concurrency/waxomatic2/WaxOMatic2.java// Using Lock and Condition objects.package concurrency.waxomatic2; import static java.lang.System.out;import java.util.concurrent.ExecutorService;...原创 2009-04-18 12:31:16 · 105 阅读 · 0 评论 -
Count Down Latch explanation
Very important paragraph on how the CountDownLatch works.CountDownLatch is a flexible latch implementation that can be used in any of these situations; it allows one or more threads to wait for a se...原创 2008-10-02 10:29:10 · 225 阅读 · 0 评论 -
Re entrantLock usage
a thread can be really interrupted by aThread.interrupt() only under 1 situation -- in blocked status wrapped with catch(InterruptedException e) {...}. Precisely, a) aThread.sleep(); b) aObje...2009-04-15 17:15:25 · 137 阅读 · 0 评论 -
new interrupt in java5
In Java 5, Thread.interrupt() is not encouraged. Instead, you are encouraged to use <1st way> aExecutorService.shutdownnow();<2nd way> aFuture<?>.cancel(true);For the 1st way...原创 2009-04-15 12:08:30 · 96 阅读 · 0 评论 -
interrupt
1) Each thread has a boolean interrupted status. 2) 3 interrupt related methods defined in Thread class public class Thread{ public void interrupt() {...} // interrupts the target threa...2009-04-15 10:57:58 · 111 阅读 · 0 评论 -
Executor Service Usage
ExecutorService exec = Executors.newCachedThreadPool();for(int i = 0; i < 10; i++){ exec.execute(new Entrance(i));//obviously Entrance is another class which implements Runnable}TimeUn...原创 2009-04-14 18:18:30 · 115 阅读 · 0 评论 -
Thread Local usage
ThreadLocal usage – from JavadocThis class provides thread-local variables. These variables differ from their normal counterparts in that each thread that accesses one (via its get or set method) ha...原创 2009-04-14 17:46:21 · 153 阅读 · 0 评论 -
Timer TimerTask usage
Timer typical usage new Timer().schedule(new TimerTask() { public void run() { System.err.println("Aborting"); System.exit(0); }//end of run }, 5000); //Terminate afte...原创 2009-04-14 12:03:19 · 86 阅读 · 0 评论 -
Scheduled Executor Service
Executor can return Executor, ExecutorService, and ScheduledExecutorService. This is very, very usful Tiger new timer. scheduler.scheduleAtFixedRate(new TimePrinter(System.out), 0, 10, SECONDS)...原创 2008-07-22 11:27:05 · 215 阅读 · 0 评论 -
Executor usage
Executor is used to arrange thread execution. Basicly speaking, just manage, how many threads are permited to run together. ExecutorService obj = Executors.newSingleThreadExecutor( ) -- only 1Execu...2008-07-22 11:04:53 · 88 阅读 · 0 评论 -
Callable Usage
The important thing need to look at is, use multiple threads(Callable), let them run together, and retrieve results from them. package com.oreilly.tiger.ch10; import java.math.BigInteger; import java....原创 2008-07-22 10:24:51 · 91 阅读 · 0 评论 -
wait, notify及线程通讯机制
1) wait(), notify() 方法被调用的时候,只要外面没有被synchronized()罩住,编译可过,但是跑起来一定发生异常--- current thread not owner 2) wait(), notify()的ref1一定要和synchronized(ref2)一致!两个ref必须是同一个东西,否则报错。3) 处于wait()状态的Thread&nb...2009-02-26 22:42:52 · 104 阅读 · 0 评论 -
javadoc for Cyclic Barrier
java.util.concurrent.CyclicBarrierA synchronization aid that allows a set of threads to all wait for each other to reach a common barrier point. CyclicBarriers are useful in programs involving a fix...原创 2009-04-24 12:48:04 · 101 阅读 · 0 评论