李敏
日歷
<
2025年6月
>
日
一
二
三
四
五
六
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1
2
3
4
5
統計
隨筆 - 1
文章 - 40
評論 - 4
引用 - 0
導航
BlogJava
首頁
發新隨筆
發新文章
聯系
聚合
管理
常用鏈接
我的隨筆
我的評論
我的參與
最新評論
留言簿
(1)
給我留言
查看公開留言
查看私人留言
文章分類
Head First(2)
(rss)
XML(2)
(rss)
應用配置(4)
(rss)
開發工具配置(9)
(rss)
算法(21)
(rss)
編碼經驗(1)
(rss)
項目代碼(1)
(rss)
文章檔案
2012年10月 (1)
2012年9月 (2)
2012年4月 (1)
2011年12月 (1)
2011年11月 (2)
2010年10月 (1)
2010年9月 (1)
2010年8月 (5)
2010年1月 (3)
2009年12月 (1)
2009年9月 (4)
2009年8月 (2)
2009年7月 (3)
2009年3月 (5)
2009年2月 (3)
2009年1月 (2)
2008年12月 (1)
2008年10月 (2)
2008年5月 (1)
相冊
Oracle
Spket
收藏夾
開發工具(1)
(rss)
它山之石
莊周夢蝶,孰蝶是我,我是孰蝶?一夢至今,蝶我已難分
聚賢莊
搜索
最新評論
1.?re: Io 異常: The Network Adapter could not establish the connection(轉)[未登錄]
評論內容較長,點擊標題查看
--liu
2.?re: Hibernate的Update語句的多屬性更新
還是不太明白使用,能幫我嗎?379899146
--Sky、超兒
3.?re: MyEclipse Enterprise Workbench 8.0 注冊碼(轉)
@byron
不好意思,忘了說明了,這個是我在網上找到的!
--李敏
4.?re: MyEclipse Enterprise Workbench 8.0 注冊碼[未登錄]
你太強大了哥們
--byron
迅雷面試題
/** */
/**
* 有三個線程ID分別是A、B、C,請用多線編程實現,在屏幕上循環打印10次ABCABC…。
*
*/
public
class
TestThread
{
private
void
service()
{
int
IDChartCount
=
ID.values().length
-
1
;
IDChart dpool
=
new
IDChart(IDChartCount);
for
(ID id : ID.values())
{
Thread t
=
new
ThreadImpl(dpool, id, id.name());
t.start();
}
}
public
static
void
main(String[] args)
{
new
TestThread().service();
}
}
enum
ID
{
a, b, c
}
class
ThreadImpl
extends
Thread
{
private
final
ID id;
private
final
IDChart chart;
public
ThreadImpl(IDChart chart, ID id, String name)
{
super
(name);
this
.chart
=
chart;
this
.id
=
id;
}
public
void
run()
{
for
(
int
i
=
0
; i
<
10
;)
{
synchronized
(chart)
{
if
(chart.check(id))
{
System.out.println(getId()
+
"
"
+
getName()
+
"
"
+
id);
i
++
;
}
}
try
{
sleep(
1
);
}
catch
(InterruptedException e)
{
//
TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
class
IDChart
{
private
int
index
=
0
;
private
final
int
count;
public
IDChart(
int
count)
{
this
.count
=
count;
}
public
boolean
check(ID id)
{
if
(index
==
id.ordinal())
{
if
(index
!=
count)
index
++
;
else
index
=
0
;
return
true
;
}
return
false
;
}
}
迅雷面試題
(
以上為我的其中一道題的個人實現
)
http://www.javaeye.com/topic/534019
posted on 2009-12-02 06:34
李敏
閱讀(381)
評論(0)
編輯
收藏
所屬分類:
算法
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發表評論。
網站導航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
相關文章:
面試題(二)———斐波那契數列
面試題(一)———截取字符串
對比兩個數組中的數,找出有重復的數
求指定日期在一個星期中的天數
處理重復數
驗證連續數
求一定范圍內的素數
迅雷面試題
楊輝三角
自定義排序輸出
Copyright © 李敏
Powered by:
博客園
模板提供:
滬江博客
主站蜘蛛池模板:
康平县
|
沈丘县
|
宕昌县
|
黄石市
|
郎溪县
|
琼结县
|
阿荣旗
|
清新县
|
威信县
|
阿城市
|
石城县
|
汕尾市
|
赫章县
|
多伦县
|
南昌市
|
昆山市
|
锡林郭勒盟
|
永顺县
|
安义县
|
资溪县
|
翁牛特旗
|
黄陵县
|
兴业县
|
舒城县
|
巨野县
|
沈阳市
|
宕昌县
|
来安县
|
台江县
|
永康市
|
大新县
|
兰坪
|
石门县
|
体育
|
康马县
|
乌苏市
|
云和县
|
固始县
|
屏山县
|
平安县
|
军事
|