我面试时的几个难题?

pyzh 2003-10-16 09:53:50
java中实现多态的机制是什么?
java中使用多线程的弊端是什么(死锁除外)?
...全文
43 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
Yanbin_Q 2003-10-16
  • 打赏
  • 举报
回复
继承和实现接口都实现了多态

线程序管道间通信也不应出现什么麻烦啊
线程序比使用进程还应节给资源才对

什么线程序切换,是线程的优先级调度吗?

怕线程没有消毁浪费资源的

对线程我也用得不多,基本上还没有用过,不太清楚。

--------------------------
他们为什么扣我的信誉分
扣我信誉分怎么没有记录
--------------------------
wzrlover 2003-10-16
  • 打赏
  • 举报
回复
进行线程切换比较耗资源
qxjavajava 2003-10-16
  • 打赏
  • 举报
回复
多线程有什么缺点--------------------- 浪费资源
hesi726 2003-10-16
  • 打赏
  • 举报
回复
类继承或者接口实现!!动态绑定!!

多线程有什么缺点啊??如果不是用锁,不能准确的知道执行顺序!
honkyjiang 2003-10-16
  • 打赏
  • 举报
回复
多态当然好理解了..... 如楼上 .
多线程 比如说不同的线程Load的class 不能相互应用 ....... 还有如下例:
public class ThreadLocal
extends Object
This 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) has its own, independently initialized copy of the variable. ThreadLocal instances are typically private static fields in classes that wish to associate state with a thread (e.g., a user ID or Transaction ID).

For example, in the class below, the private static ThreadLocal instance (serialNum) maintains a "serial number" for each thread that invokes the class's static SerialNum.get() method, which returns the current thread's serial number. (A thread's serial number is assigned the first time it invokes SerialNum.get(), and remains unchanged on subsequent calls.)

public class SerialNum {
// The next serial number to be assigned
private static int nextSerialNum = 0;

private static ThreadLocal serialNum = new ThreadLocal() {
protected synchronized Object initialValue() {
return new Integer(nextSerialNum);
}
};

public static int get() {
return ((Integer) (serialNum.get())).intValue();
}
}
Each thread holds an implicit reference to its copy of a thread-local variable as long as the thread is alive and the ThreadLocal instance is accessible; after a thread goes away, all of its copies of thread-local instances are subject to garbage collection (unless other references to these copies exist).
yixiaojiao 2003-10-16
  • 打赏
  • 举报
回复
up
Veeve 2003-10-16
  • 打赏
  • 举报
回复
1.继承接口
2.略(因为不懂)

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧