capturethread.java

来自「java开发的netbeans插件中的application原型」· Java 代码 · 共 55 行

JAVA
55
字号
/*
 * CaptureThread.java
 *
 * Created on 2006年11月24日, 下午11:31
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package cn.edu.tsinghua.thss.talkie.capture;

import cn.edu.tsinghua.thss.talkie.connect.Connect;
import java.awt.image.BufferedImage;

/**
 *
 * @author promenade
 */
public class CaptureThread implements Runnable {
    
    BufferedImage screen = null;
    Capturer capturer = null;
    Connect connection = null;

    /** Creates a new instance of CaptureThread */
    public CaptureThread( Connect connection ) {
        capturer = new Capturer();
        this.connection = connection;
        ( new Thread(this,"capture Thread") ).start();
    }
    
    public void run() {
        long time;
        while( !Thread.currentThread().interrupted() ){
            time = System.currentTimeMillis();
            System.out.print("Start capturing...");
            screen = capturer.capture();
            time = System.currentTimeMillis()-time;
            System.out.print( time + " milliseconds used to capture");
            
            time = System.currentTimeMillis();
            connection.sendImage( screen );
            time = System.currentTimeMillis()-time;
            System.out.println( time + " milliseconds used to send");
            
//            try {
//                Thread.sleep( 1000 );
//            } catch (InterruptedException ex) {
//                ex.printStackTrace();
//            }
        }
    }
    
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?