Tricks of the Java Programming Gurus

In the world of programming, there are usually two types of ways to code Java: the optimized way and the way that gets the product into production before the deadline. However, with the right skill-set, a programmer can find ways and means to make every program fun faster and tighter despite even the most compressed time frames before completion. Variables, multimedia, image rendering and data retrieval are just some of the Java topics tackled in this comprehensive free download book. If you've ever wondered how to get the most out of every line of Java code you author, this is the free book is for you.

 

starting day

2011.01.24

 

Chapter 2 : Using the Media Tracker

in source code searching...

 

i just came upon such situation

 

public void run() {
    try {
        tracker.waitForID(0);
    } catch (InterruptedException e) {
        return;
    }
    
    repaint();
}
 

and as it says:

 

The run method is where the tracking actually starts taking place. The waitForID method of
MediaTracker is called within a try-catch clause. It must be placed in this exception handling
clause because an InterruptedException will be thrown if another thread interrupts this thread.
Recall that waitForID is synchronous , meaning that it won't return until all the images with the
specified identifier have been loaded. This means that the call to repaint will not occur until the
images have all been loaded.

 

you see, here why it calls the waitForID method is synchronous, no synchronous identifier was found attached before the method name according to the jdk1.6 javadoc...

so i think it just means it does not open another thread to do the work, so...it's synchronous, right!?

the related code will be put in another thread, see:

http://dracularking.iteye.com/blog/893957


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值