datagenerator.java

来自「通过线程控制来打印出julia集」· Java 代码 · 共 28 行

JAVA
28
字号
public class DataGenerator implements Runnable {
	int imageWidth, imageHeight, color;

	DataPacket p;

	DataBuffer inputBuffer;

	DataGenerator(int imageWidth, int imageHeight, DataBuffer inputBuffer) {
		this.imageWidth = imageWidth;
		this.imageHeight = imageHeight;
		this.inputBuffer = inputBuffer;
	}

	public void run() {
		while (true) {
			color = 7;					//the highest no. of colors
			p = new DataPacket((int) (imageWidth * Math.random()),	
					(int) (imageHeight * Math.random()), color);
						//chooses a pair of random coordinate swith in the image area
			inputBuffer.put(p);			//put this packet to inputBuffer
			try {
				Thread.sleep(5);		
			} catch (InterruptedException e) {
			}
		}
	}
}

⌨️ 快捷键说明

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