问题 单项选择题

下列情况中,不会使线程返回所持有的对象锁的是( )。

A.当synchronized()语句块执行完毕

B.当调用了线程的suspend()方法

C.当在synchronized()语句块中出现异常(Exceptio

D.当持有锁的线程调用该对象的wait()方法

答案

参考答案:B

解析: 本题考查Java线程中对象的加锁及其操作。对象加锁的使用非常灵活,一定要注意。对象的锁在如下几种情况下由持有线程返还:当synchronized()语句块执行完后,所以选项A错误;当在synchronized()语句块中出现异常 (exception),所以选项B错误;当持有锁的线程调用该对象的wait()方法,此时该线程将释放对象的锁,所以选项D错误。而当调用了线程的suspend()方法只是使线程暂时停止执行,可以使用其他线程调用resume()方法恢复执行,所以选项B正确。

阅读理解

阅读理解。

    Two magazines recently listed the best cities to live in. Here are two of the cities listed as "the world's

best."

    SAN JOSE, COSTARICA The city has comfortable weather all year round (15℃to 26℃). Housing is

not very expensive in SAN JOSE. Also, many of the city's older neighborhoods are very beautiful and have

small hotels and cafes. Beautiful mountains are around the city. Lots of people go sightseeing there every

year. But air pollution is a problem in the city center.

    Hong Kong, CHINA This lively city-once a small fishing village-is today an international business center.

It is an interesting mix of East and West, old and new. Modern tall buildings are next to small temples (庙宇).

Popular nightclubs are close to traditional teahouses. Busy people fill the streets at all hours of the day. But

outside the city, there are parks for walking or relaxing. Hong Kong is famous for its wonderful native dishes.

There's also food from Europe, North America, and other parts of Asia. However, this small city has a large

population of nearly seven million! That's why housing is often very expensive. Traffic and air pollution are

also a problem.

1. Which of the following is NOT mentioned about San Jose?

A. The weather

B. The mountains

C. The air

D. The traffic

2. What makes Hong Kong the world's best according to this passage?

A. The lively city and the wonderful dishes.

B. The large population and the traffic.

C. The expensive housing.

D. The beautiful temples.

3. The writer thinks housing in Hong Kong is expensive because _______.

A. it was a small fishing village

B. it is a mix of East and West

C. it is famous for its wonderful food

D. there are too many people in the city

4. What do the two cities have in common?

A. They both have beautiful mountains.

B. They both have a large population.

C. Air pollution is a problem in both cities.

D. They are both crowded.

5. From the passage, we can know that ______.

A. San Jose and Hong Kong are the only two cities of the world's best.

B. Housing in San Jose is not very expensive.

C. the weather in both cities is fine.

D. San Jose used to be a small fishing village.

单项选择题