본문 바로가기

공부/컴퓨터

쪽팅 클라이언트 - 스레드 실행 간격 0.2초 가능

반응형
스레드를 실행 시키는 간격이 0.2초 정도라면
거의 cpu를 소모 하지 않는다고 함.

대신 쪽지 클라이언트일때만 가능할 것임.

( 서버라면 순식간에 들어 오는 사람을 모두 처리해야 함으로 )
( 채팅 클라이언트라도 빠른 속도를 위해서라면 ?  잘 모르겠음 )

http://mjava.net

114:         public void run() {
115:                 System.out.println("webclient run");
116:                 int ttime = 200; //thread sleep time;
117:                 int mtime = 0; //memo time;
118:                 int ctime = 0; //check time;
119:                 while(!isStop) {
120:                         try {
121:                        
122:                                 // 0.2초단위로 쓰레드가 쓰레드가 실행되도록 함..
123:                                 // 0.2초라하지만 로컬 시스템의 cpu를 거의 소모하지 않는다.
124:                                 if(this.isLoginCheck) {
125:                                         ctime += ttime;
126:                                         if(ctime > checkLoginTime) {
127:                                                 ctime = 0;
128:                                                 checkLoginUser();
129:                                         }
130:                                 }
131:                                
132:                                 if(this.isNewMemoCheck) {
133:                                         mtime += ttime;
134:                                         if(mtime > dtime) {
135:                                                 mtime = 0;                                        
136:                                                 checkNewMemo();
137:                                         }        
138:                                 }
139:                                
140:                                 thread.sleep(ttime);
141:                                
142:                        
143:                                
144:                         } catch(InterruptedException e) {
145:                                
146:                         }
147:                                
148:                 }
=======================================================
반응형