首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

gearman 处置类

2012-10-17 
gearman 处理类import java.util.ArrayListimport java.util.Listimport org.gearman.client.GearmanJob

gearman 处理类

import java.util.ArrayList;import java.util.List;import org.gearman.client.GearmanJobResult;import org.gearman.client.GearmanJobResultImpl;import org.gearman.util.ByteUtils;import org.gearman.worker.AbstractGearmanFunction;//真正的业务逻辑public class ReverseFunction extends AbstractGearmanFunction {        public GearmanJobResult executeFunction() {    GearmanJobResult gjr=null;      //  StringBuffer sb = new StringBuffer(ByteUtils.fromUTF8Bytes((byte[]) this.data));        for(int i=0;i<10;i++){         StringBuffer sb = new StringBuffer(ByteUtils.fromUTF8Bytes((byte[]) this.data));                 gjr = new GearmanJobResultImpl(this.jobHandle,                true, sb.reverse().toString().getBytes(),                new byte[0], new byte[0], 0, 0);         System.out.println("--"+sb.toString()+"--");         try {Thread.sleep(1000);} catch (InterruptedException e) {// TODO Auto-generated catch blocke.printStackTrace();}        }        return gjr;    }}class show extends Thread{  public void run(){  ClientTest test=new ClientTest("192.168.101.143", 4730);             System.out.println(test.reverse("hello"));  } }

热点排行