posts - 39,  comments - 263,  trackbacks - 0
            2008年8月21日
              這幾天用TimerTask作了個框架,擔心超過十萬條數據的時候速度變慢,其實每秒十萬次的運行速度等到以后放在服務器上運行應該游刃有余吧,還不清楚,不過現在在我筆記本上運行得還可以,內存吃的很大,java就這毛病,程序員不能自由釋放內存。1G內存不夠用,我筆記本2G有分配不了,似乎虛擬內存java用不了,沒仔細做過實驗。
              這幾天看新聞知道番茄花園作者被警方逮捕,樹大招風,槍打出頭鳥,很正常,從程序員的身份來講,盜版是要打擊的,不過我本身電腦里要付費的軟件都是盜版的,很矛盾,呵呵。
          posted @ 2008-08-21 23:54 nake 閱讀(2154) | 評論 (3)編輯 收藏
            2008年7月12日
          實在太久沒寫servlet了,應該至少1年了,那時候做了點皮毛,現在項目要求用到servlet的相關知識,同時我在blogjava的bolg又開張了。學習的過程將記錄在我的blog中。對比了一下netbean和eclipse感覺用netbean編寫servlet程序方便些,eclipse用了幾年,但是還是感覺每次要找好相關的jar需要花費太多時間,于是決定用netbean編寫了。
          posted @ 2008-07-12 15:15 nake 閱讀(1949) | 評論 (2)編輯 收藏
            2007年1月14日
          看看以下代碼:
          將26個英文字母重復加了5000次,

          String tempstr = "abcdefghijklmnopqrstuvwxyz";
          int times = 5000;
          long lstart1=System.currentTimeMillis();
          ??String str ="";
          ??for(int i=0;i<times;i++)
          ??{
          ???str+=tempstr;
          ??}
          ??
          ??long lend1=System.currentTimeMillis();
          ??long time = (lend1-lstart1);
          ??System.out.println(time);

          可惜我的計算機不是超級計算機,得到的結果每次不一定一樣一般為 154735 左右。
          也就是154秒。
          我們再看看以下代碼

          String tempstr = "abcdefghijklmnopqrstuvwxyz";
          ?
          ??int times = 5000;
          long lstart2=System.currentTimeMillis();
          ??StringBuffer sb =new? StringBuffer();
          ??for(int i=0;i<times;i++)
          ??{
          ???sb.append(tempstr);
          ???
          ??}
          ??long lend2=System.currentTimeMillis();
          ??long time2 = (lend2-lstart2);
          ??System.out.println(time2);
          ?得到的結果為 16 有時還是 0
          所以結論很明顯,StringBuffer 的速度幾乎是String 上萬倍。當然這個數據不是很準確。因為循環的次數在100000次的時候,差異更大。不信你試試。
          下一次我將解釋為什么StringBuffer 的效率比String 高這么多。
          posted @ 2007-01-14 12:24 nake 閱讀(4223) | 評論 (4)編輯 收藏
            2007年1月3日

          swt 簡單的托盤程序
          java寫和操作系統相關的程序難度非常大。在java 6出現之前,如果你想實現一個托盤程序,最簡單的就是用swt了。
          通過google我找到了一段代碼。
          其實很簡單。主要的代碼如下:
          ?????????????final Tray tray = display.getSystemTray();
          ??????????? final TrayItem trayItem = new TrayItem(tray, SWT.NONE);
          ??????????? Image image = new Image (display, 16, 16);
          ??????????? trayItem.setImage(image);
          知道了重點,事情變的很簡單了。看看所有程序
          //-----------------
          public class SystemTray extends Shell {
          ??? public static void main(String args[]) {
          ??????? try {
          ??????????? Display display = Display.getDefault();
          ??????????? SystemTray shell = new SystemTray(display, SWT.SHELL_TRIM);
          ?????????? // shell.createSystemTray(shell);
          ??????????? final Tray tray = display.getSystemTray();
          ??????????? final TrayItem trayItem = new TrayItem(tray, SWT.NONE);
          ??????????? Image image = new Image (display, 16, 16);
          ??????????? trayItem.setImage(image);
          ??????????? shell.open();
          ??????????? shell.layout();
          ??????????? while (!shell.isDisposed()) {
          ??????????????? if (!display.readAndDispatch())
          ??????????????????? display.sleep();
          ??????????? }
          ??????? } catch (Exception e) {
          ??????????? e.printStackTrace();
          ??????? }
          ??? }
          ??? public SystemTray(Display display, int style) {
          ??????? super(display, style);
          ??????? createContents();
          ??? }

          ??? /**
          ???? * Create contents of the window
          ???? */
          ??? protected void createContents() {
          ??????? setText("SWT Application");
          ??????? setSize(500, 375);

          ??? }
          ??? //swt 默認情況下不允許shell被繼承
          ??? //所以我重載了父類的方法
          ??? protected void checkSubclass() {
          ???????? }
          }
          //--------------------
          如果你想成功運行以上代碼,你最好在eclipse下新建一個swt的類。具體操作你搜索一下吧。
          但是上面的代碼只是加入了托盤,這可能是最簡單的實現托盤的程序了。我們加入事件處理,讓程序能夠最大和最小化。然后把托盤用圖片來表示。
          詳細的代碼不參考
          下載 到eclipse里運行

          posted @ 2007-01-03 22:58 nake 閱讀(3417) | 評論 (4)編輯 收藏
          僅列出標題  下一頁
          <2025年5月>
          27282930123
          45678910
          11121314151617
          18192021222324
          25262728293031
          1234567

          常用鏈接

          留言簿(18)

          我參與的團隊

          隨筆檔案(39)

          收藏夾(1)

          搜索

          •  

          積分與排名

          • 積分 - 451366
          • 排名 - 119

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 乌兰县| 汽车| 五家渠市| 南丹县| 屏边| 石柱| 漾濞| 芒康县| 天全县| 云安县| 新野县| 吴江市| 棋牌| 营山县| 远安县| 新晃| 宜都市| 延川县| 喀喇沁旗| 高州市| 张掖市| 泾川县| 临城县| 和平县| 凤庆县| 青海省| 潮安县| 临夏县| 鸡泽县| 唐海县| 双鸭山市| 随州市| 大新县| 长沙市| 新建县| 福建省| 靖宇县| 库车县| 玉山县| 土默特右旗| 黑河市|