⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getimage.java

📁 运用HTTPCONNECTION做一个简单的聊天程序
💻 JAVA
字号:
package datagram003packet;
import javax.microedition.io.*;
import javax.microedition.lcdui.*;//use the image
public class GetImage extends Thread implements Runnable {

	private DatagramConnection dc;
	private Image image;
	private boolean running=true;
	////
	
	private static int count=0;
	public GetImage(DatagramConnection dc)
	{
		this.dc=dc;
	     	
		this.start();
	}
	public synchronized void startRun()
	{
		this.running=true;
		if(this.running==true)
		{
			try
			{
				this.notify();
			}
			catch(Exception e)
			{
				e.printStackTrace();
			}
		}
	}
	public synchronized void stopRun()
	{
		this.running=false;
		try
		{
			this.notify();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	}
	public synchronized void run()
	{
		while(true)
		{
			try
			
			{
				if(running=true)
				{
					this.wait();
				}
				if(running=false)
				{
					break;
				}
				System.out.println("GetImage.run()");
				Datagram dg=dc.newDatagram(45000);
				System.out.println("GetImaeg.dg::"+dg);
				byte[]buf=dg.getData();
				image=Image.createImage(buf,0, buf.length);
				System.out.println("image::"+image);
			    count++;
			}
			catch(Exception e)
			{
				e.printStackTrace();
			}
			//stopRun();
			running=true;
		}
	}
	public synchronized Image getImage()
	{
		return image;
	}
}

⌨️ 快捷键说明

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