Thread Test

개발/Java 2006/01/05 17:44

[CODE type="java"]
/** 쓰레드 연습 **/
class Data{
[tab]
[tab]private String data;
[tab]private boolean is_saved = false;
[tab]
[tab]public synchronized void setData(String arg){
[tab][tab]
[tab][tab] try{
[tab][tab][tab] 
[tab][tab][tab] 
[tab][tab][tab]  if(is_saved){
[tab][tab][tab][tab]   wait();
[tab][tab][tab]  }
[tab][tab] }
[tab][tab] catch (Exception e) {
[tab][tab][tab]  System.out.println("SET error");
[tab][tab] }
[tab][tab]
[tab][tab] data = arg;
[tab][tab] is_saved = true;
[tab][tab] notify();
[tab][tab]
[tab]}
[tab]public synchronized  String getData(){
[tab][tab]
[tab][tab] try{
[tab][tab][tab]  if(!is_saved)
[tab][tab][tab][tab]   wait();
[tab][tab][tab] 
[tab][tab] }
[tab][tab] catch (Exception e) {
[tab][tab][tab]  System.out.println("GET error");
[tab][tab] }
[tab][tab]
[tab][tab] String r = data;
[tab][tab] data = "";
[tab][tab] is_saved =false;
[tab][tab] notify();
[tab][tab] return r;
[tab]}
[tab]
[tab]
[tab]public boolean is_saved(){
[tab][tab] return is_saved;[tab][tab] 
[tab]}
[tab]
}

class Producer extends Thread{
[tab]Data s;
[tab]Producer(String msg, Data ss){
[tab][tab] s=ss;
[tab][tab] System.out.println(msg);[tab][tab] 
[tab]}
[tab]public void run(){
[tab][tab] int i=0;

[tab][tab] while(i<10){
[tab][tab][tab]  try{
[tab][tab][tab]  sleep((long)(Math.random()*1000));
[tab][tab][tab]  }
[tab][tab][tab]  catch (Exception e) {
[tab][tab][tab][tab]   // TODO: handle exception
[tab][tab][tab]  }
[tab][tab][tab] 
[tab][tab][tab]  System.out.println( "producer is running : " +i);
[tab][tab][tab]  s.setData("DATA ("+i+"): " + produce());
[tab][tab][tab][tab]   i++;
[tab][tab]
[tab][tab] }//end while

[tab]}//end run
[tab]
[tab]private String produce(){
[tab][tab] int r ;
[tab][tab] r =(int)( Math.random()*10);
[tab][tab] return "" + r;
[tab]}
[tab]
}
class Consumer extends Thread{
[tab]Data s;[tab]
[tab]
[tab]Consumer(String msg,Data ss){
[tab][tab] s = ss;
[tab]
[tab][tab] System.out.println(msg);
[tab]}
[tab]
[tab]public void run(){
[tab][tab] int i=0;
[tab][tab] String data="";

[tab][tab] while(i<10){
[tab][tab][tab]  try{
[tab][tab][tab][tab]   sleep((long)(Math.random()*1000));
[tab][tab][tab][tab]   }
[tab][tab][tab][tab]   catch (Exception e) {
[tab][tab][tab][tab][tab]    // TODO: handle exception
[tab][tab][tab][tab]   }
[tab][tab][tab][tab]  
[tab][tab][tab]  System.out.println( "consumer is running : " + i);
[tab][tab][tab]  data =s.getData();
[tab][tab][tab]  System.out.println(">> " +  data);

[tab][tab][tab]  i++;

[tab][tab][tab] 
[tab][tab] }//end while

[tab]}//end run[tab]
}

class Ttest{
[tab]public static void main(String args[])
[tab]{
[tab][tab] Data data = new Data();
[tab][tab] Producer t1 = new Producer("P thread is ready", data);
[tab][tab] Consumer c1 = new Consumer("C thread is ready", data);
[tab][tab]
[tab][tab]
[tab][tab] t1.start();
[tab][tab] c1.start();
[tab][tab]
[tab][tab]
[tab][tab]
[tab][tab][tab][tab]  
[tab]}[tab][tab] 
}

/**

class Data{
[tab]
[tab]private String data;
[tab]private boolean is_saved = false;
[tab]
[tab]public void setData(String arg){
[tab][tab] data = arg;
[tab][tab] is_saved = true;
[tab]}
[tab]public String getData(){
[tab][tab] String r = data;
[tab][tab] data = "";
[tab][tab] is_saved =false;
[tab][tab] return r;
[tab]}
[tab]
[tab]
[tab]public boolean is_saved(){
[tab][tab] return is_saved;[tab][tab] 
[tab]}
[tab]
}

class Producer extends Thread{
[tab]Data s;
[tab]Producer(String msg, Data ss){
[tab][tab] s=ss;
[tab][tab] System.out.println(msg);[tab][tab] 
[tab]}
[tab]public void run(){
[tab][tab] int i=0;

[tab][tab] try{
[tab][tab][tab]  while(i<10){
[tab][tab][tab][tab]  
[tab][tab][tab][tab]   System.out.println( "producer is running : " +i);
[tab][tab][tab][tab]   if(s.is_saved()){
[tab][tab][tab][tab][tab]    yield();
[tab][tab][tab][tab]   }
[tab][tab][tab][tab]   else{
[tab][tab][tab][tab][tab]    s.setData("DATA ("+i+"): " + produce());
[tab][tab][tab][tab][tab]    i++;
[tab][tab][tab][tab]   }
[tab][tab][tab][tab]  
[tab][tab][tab]  }//end while
[tab][tab] }
[tab][tab] catch (Exception e) {
[tab][tab][tab]  System.out.println(e);
[tab][tab][tab]  // TODO: handle exception
[tab][tab] }
[tab]}//end run
[tab]
[tab]private String produce(){
[tab][tab] int r ;
[tab][tab] r =(int)( Math.random()*10);
[tab][tab] return "" + r;
[tab]}
[tab]
}
class Consumer extends Thread{
[tab]Data s;[tab]
[tab]
[tab]Consumer(String msg,Data ss){
[tab][tab] s = ss;
[tab]
[tab][tab] System.out.println(msg);
[tab]}
[tab]
[tab]public void run(){
[tab][tab] int i=0;
[tab][tab] String data="";

[tab][tab] try{
[tab][tab][tab]  while(i<10){
[tab][tab][tab][tab]   System.out.println( "consumer is running : " + i);
[tab][tab][tab][tab]   if(s.is_saved()){
[tab][tab][tab][tab][tab][tab]     data =s.getData();
[tab][tab][tab][tab][tab][tab]     System.out.println(">> " +  data);
[tab][tab][tab][tab][tab][tab]     //notifyAll();
[tab][tab][tab][tab][tab][tab]     i++;
[tab][tab][tab][tab]   }
[tab][tab][tab][tab]   else{
[tab][tab][tab][tab][tab]    yield();
[tab][tab][tab][tab][tab]    yield();
[tab][tab][tab][tab][tab]   
[tab][tab][tab][tab][tab]    //this.wait();
[tab][tab][tab][tab][tab]    //this.suspend();
[tab][tab][tab][tab]   }
[tab][tab][tab][tab]  
[tab][tab][tab]  }//end while
[tab][tab] }
[tab][tab] catch (Exception e) {
[tab][tab][tab]  System.out.println(e);
[tab][tab][tab]  // TODO: handle exception
[tab][tab] }
[tab]}//end run[tab]
}

class Ttest{
[tab]public static void main(String args[])
[tab]{
[tab][tab] Data data = new Data();
[tab][tab] Producer t1 = new Producer("P thread is ready", data);
[tab][tab] Consumer c1 = new Consumer("C thread is ready", data);
[tab][tab]
[tab][tab]
[tab][tab] t1.start();
[tab][tab] c1.start();
[tab][tab]
[tab][tab]
[tab][tab]
[tab][tab][tab][tab]  
[tab]}[tab][tab] 
}
**/

[/HTML][/CODE]

2006/01/05 17:44 2006/01/05 17:44

대구시내버스 노선 조회 사이트에서 -_-;
여러가지 제약때문에,

버스 정류장 리스트를 쫘악뽑아서
txt파일로 만든다음

이것을 db에 집어넣기위해서
sql 형식으로 바꿔야되는데,

excel, access 로 뻘짓하다가
결국 c++로 parser를 제작 -_-

sql 구문을 손에 넣다 -_-;
2006/01/04 00:44 2006/01/04 00:44

msn bot
SBsession 처리 작업도중 ;
이 문제로 몇시간동안 삽질끝에 method overriding으로 해결

class SBField{
       public long SB;
       public int Code;
       
       
       public boolean equals(Object obj){
               SBField f = (SBField)obj;
               
               if(this.SB==f.SB && this.Code == f.Code)
                       return true;
               
               return false;
       }
}


...
...
...

public int find(SBField element){
       
       ListIterator li = list.listIterator();
       
       while(li.hasNext()){
               //System.out.println( li.nextIndex() + ":" + li.next().equals((Object)element) );
               
               Object next = li.next();
               
               //System.out.println(next);
               if(next.equals((Object)element))
                       return li.nextIndex()-1;

       }
       
       return -1;
}
2006/01/01 16:49 2006/01/01 16:49

안녕하세요.
http://www.rootman.co.kr 운영자 정찬호입니다.

rkhunter는 rootkit을 찾아 주는 유틸리티로 설치도 간단하고 보는 법도 간단합니다.
또한 중요 파일에 대한 위, 변조를 알려 주어 관리자로 하여금 약간 안도감을 주는^^ 프로그램이죠.

혹시 모르셨던 분들 한 번 써 보세요.
도움이 꼭 되시길 바라면서.

Have a good time !


1. 관련사이트
  http://www.rootkit.nl/projects/rootkit_hunter.html


2. 소스 다운로드
  (1) http://downloads.rootkit.nl/rkhunter-1.2.7.tar.gz
  (2) http://mirror.1day.co.kr/download/Security/rkhunter-1.2.7.tar.tar


3. 설치
[root@ns1 /usr/local/src]# tar xvfz rkhunter-1.2.7.tar.tar
[root@ns1 /usr/local/src]# cd rkhunter-1.2.7
[root@ns1 rkhunter-1.2.7]# ./installer.sh
Rootkit Hunter installer 1.2.7 (Copyright 2003-2005, Michael Boelen)
---------------
Starting installation/update

Checking  /usr/local... OK
Checking file retrieval tools... /usr/bin/wget
Checking installation directories...
- Checking /usr/local/rkhunter...Created
- Checking /usr/local/rkhunter/etc...Created
- Checking /usr/local/rkhunter/bin...Created
- Checking /usr/local/rkhunter/lib/rkhunter/db...Created
- Checking /usr/local/rkhunter/lib/rkhunter/docs...Created
- Checking /usr/local/rkhunter/lib/rkhunter/scripts...Created
- Checking /usr/local/rkhunter/lib/rkhunter/tmp...Created
- Checking /usr/local/etc...Exists
- Checking /usr/local/bin...Exists
Checking system settings...
  - Perl... OK
Installing files...
Installing  Perl module checker... OK
Installing  Database updater... OK
Installing  Portscanner... OK
Installing  MD5 Digest generator... OK
Installing  SHA1 Digest generator... OK
Installing  Directory viewer... OK
Installing  Database Backdoor ports... OK
Installing  Database Update mirrors... OK
Installing  Database Operating Systems... OK
Installing  Database Program versions... OK
Installing  Database Program versions... OK
Installing  Database Default file hashes... OK
Installing  Database MD5 blacklisted files... OK
Installing  Changelog... OK
Installing  Readme and FAQ... OK
Installing  Wishlist and TODO... OK
Installing  RK Hunter configuration file... OK
Installing  RK Hunter binary... OK
Configuration updated with installation path (/usr/local/rkhunter)

Installation ready.
See /usr/local/rkhunter/lib/rkhunter/docs for more information. Run 'rkhunter' (/usr/local/bin/rkhunter)


4. 실행 파일 복사
[root@ns1 rkhunter-1.2.7]# cp rkhunter /usr/sbin/


5. 시스템 검사하기
(1) 검사 레포트 crt 출력
[root@ns1 rkhunter-1.2.7]# rkhunter -c

(2) 검사 파일 저장하기
[root@ns1 rkhunter-1.2.7]# rkhunter --checkall --createlogfile
....
....
---------------------------- Scan results ----------------------------
MD5
MD5 compared: 0
Incorrect MD5 checksums: 0

File scan
Scanned files: 342
Possible infected files: 0

Application scan
Vulnerable applications: 3

Scanning took 365 seconds
Scan results written to logfile (/var/log/rkhunter.log)


6. 버전 확인하기
[root@ns1 rkhunter-1.2.7]# /usr/local/bin/rkhunter --versioncheck
http://www.rootkit.nl/rkhunter/rkhunter_latest.dat

Rootkit Hunter 1.2.3, copyright Michael Boelen

This version:   1.2.3
Latest version: 1.2.7
Update available


7. rkhunter 업데이트하기
[root@ns1 root]# /usr/local/bin/rkhunter --update     
Running updater...

Mirrorfile /usr/local/rkhunter/lib/rkhunter/db/mirrors.dat rotated
Using mirror http://www.rootkit.nl/rkhunter
[DB] Mirror file                      : Update available
  Action: Database updated (current version: 2005033000, new version 2005050700)
[DB] MD5 hashes system binaries       : Update available
  Action: Database updated (current version: 2005041000, new version 2005080200)
[DB] Operating System information     : Update available
  Action: Database updated (current version: 2005032500, new version 2005091100)
[DB] MD5 blacklisted tools/binaries   : Up to date
[DB] Known good program versions      : Update available
  Action: Database updated (current version: 2005040300, new version 2005071500)
[DB] Known bad program versions       : Update available
  Action: Database updated (current version: 2005040300, new version 2005071500)

Ready.

- 이상 -

2005/12/25 17:45 2005/12/25 17:45

HTMLtest

개발/Java 2005/12/24 11:46
html 읽기 소스
2005/12/24 11:46 2005/12/24 11:46

<body oncontextmenu="return false" ondragstart="return false" onselectstart="return false">

ㅇㅇㄴㅣㅏㄴㅣㅇㅏ
2005/12/23 16:46 2005/12/23 16:46

로컬 프로젝트는 비워둬도 되고,
리모트디렉토리에
절대경로를 적어준다

/home/kfmes/public_html/dboard/

혹시 안되면,
passive 모드 체크!

2005/12/22 19:23 2005/12/22 19:23

cvs 서버 구축

리눅스 2005/12/21 19:03
# default: on
# description: The cvspsever serves CVS Password Server sessions; it uses \
#          unencrypted username/password pairs for authentication.
service cvspserver
{
       disable         = no
       flags           = REUSE
       socket_type     = stream
       wait            = no
       user            = root
       server          = /usr/bin/cvs
       server_args     = -f --allow-root=/home/cvs pserver
       log_on_failure  += USERID
}

/etc/xinetd.d/ 디렉토리에 cvspserver 파일을 만든다
xinetd 재시작

관련 문서
http://wiki.kldp.org/wiki.php/DocbookSgml/CVS%5FTutorial-KLDP
2005/12/21 19:03 2005/12/21 19:03

카트폐인(뒷북)

재미 2005/12/20 23:20

대략 뒷북ㅋㅋ
2005/12/20 23:20 2005/12/20 23:20

cvs 사용기

리눅스 2005/12/20 04:27
이번에 msn bot 을 만들기 시작하면서, 소스 관리를 cvs 로 하기로 마음 먹었다. cvs 서버 설정, 계정 설정, 프로젝트 추가 등등 몇시간의 삽질 끝에, 지금은 대략 cvs 사용법을 알게 된것 같다. 한번 써 보니깐 - 정말 편해서 쓰기가 좋다 ㅎ
2005/12/20 04:27 2005/12/20 04:27