sample

package com.aig.ecompassios.ecard;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

import net.sf.json.JSONObject;

public class EcardThread extends Thread {
static int i=0;
static String ebToken="";
static long time;
public EcardThread(int i,String ebToken){
this.i = i;
this.ebToken = ebToken;
}
public static String login(){
// String login ="http://10.72.3.53:7042/eCOMPASS/AppleWebService?_command_=AppleWebService&module=LoginSecurityModule&actionType=UserLogin&locale=en_HK&userId=ecarduser&password=b123456b&deviceId=A5B08C51-2092-5F39-A2C2-D79AE01A27AE&deviceType=iPhone%20Simulator&deviceToken=ajsdiofjaosidjf09a9h2093f";
String login = "http://localhost:9080/eCOMPASS/AppleWebService?_command_=AppleWebService&module=LoginSecurityModule&actionType=UserLogin&locale=en_HK&userId=member_lily002&password=a123456a&deviceId=A5B08C51-2092-5F39-A2C2-D79AE01A27AE&deviceType=iPhone%20Simulator&deviceToken=ajsdiofjaosidjf09a9h2093f";
URL loginUrl;

StringBuilder jsonLogin = new StringBuilder();
//login url
try {
loginUrl = new URL(login);
HttpURLConnection urlcon = (HttpURLConnection)loginUrl.openConnection();
urlcon.connect(); //获取连接
InputStream is = urlcon.getInputStream();
BufferedReader buffer = new BufferedReader(new InputStreamReader(is,"UTF-8"));
String l = null;
while((l=buffer.readLine())!=null){
jsonLogin.append(l);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(jsonLogin.toString());
JSONObject jsonObject = JSONObject.fromObject(jsonLogin.toString());
ebToken = jsonObject.getString("ebToken");
return ebToken;
}
public void run() {
String ecard="http://localhost:9080/eCOMPASS/AppleWebService?_command_=AppleWebService&module=ECardModule&actionType=eCardImageInformation&locale=en_HK&ebToken=";
//String ecard = "http://10.72.3.53:7042/eCOMPASS/AppleWebService?_command_=AppleWebService&module=ECardModule&actionType=eCardImageInformation&locale=en_HK&ebToken=";
long begintime = System.currentTimeMillis();
StringBuilder jsonECard = new StringBuilder();
try {
//ECard url
Thread.sleep(1000);
URL eCardURL = new URL(ecard+ebToken);
HttpURLConnection urlconECard = (HttpURLConnection)eCardURL.openConnection();
urlconECard.connect(); //获取连接
InputStream isECard = urlconECard.getInputStream();
BufferedReader bufferECard = new BufferedReader(new InputStreamReader(isECard,"UTF-8"));
String lECard = null;
while((lECard=bufferECard.readLine())!=null){
jsonECard.append(lECard);
}
System.out.println(jsonECard.toString());
System.out.println("Thread"+i+"执行时间为:"+(System.currentTimeMillis()-begintime)+"毫秒");
time+=(System.currentTimeMillis()-begintime);
System.out.println(time+"++++++");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();

}
}

public static void main(String[] args) {
long begintime = System.currentTimeMillis();
String ebToken = login();
/*for (int i = 0; i < 2; i++) {
EcardThread th = new EcardThread(i,ebToken);
th.start();
}*/
System.out.println(time+"=======");
while(time<0.3*60*1000){
EcardThread th = new EcardThread(i,ebToken);
th.start();
i=i+1;
}
System.out.println("总执行时间为:"+(System.currentTimeMillis()-begintime)+"毫秒");
}
}

时间: 2024-10-03 15:23:48

sample的相关文章

随机抽样一致算法(Random sample consensus,RANSAC)

作者:桂. 时间:2017-04-25  21:05:07 链接:http://www.cnblogs.com/xingshansi/p/6763668.html 前言 仍然是昨天的问题,别人问到最小二乘.霍夫变换.RANSAC在直线拟合上的区别.昨天梳理了霍夫变换,今天打算抽空梳理一下RANSAC算法,主要包括: 1)RANSAC理论介绍 2)RANSAC应用简介: 内容为自己的学习记录,其中很多地方借鉴了别人,最后一起给出链接. 一.RANSAC理论介绍 普通最小二乘是保守派:在现有数据下,

Sample Testlink API client in python

""" Testlink API Sample Python Client implementation """ import xmlrpclib class TestlinkAPIClient: # substitute your server URL Here SERVER_URL = "http://localhost/testlink/lib/api/xmlrpc.php" def __init__(self, dev

Sample Apps by Android Team -- Amazed

Sample Apps by Android Team 代码下载:http://pan.baidu.com/s/1eSNmdUE 本次是项目Amazed代码学习记录. 一.创建自定义View @.在onSizeChanged中,通过如参w(宽)和h(高)的比较来判断手机是处于横向(Landscape)还是纵向(Portrait). @.在onDraw中进行自定义View的界面绘制. @.绘制界面需要Canvas和Paint: 1.Cnavas:用来控制画什么,比如画直线(drawLine).画矩

openstack4j a java sample demo

This is  A sample Demo package edu.hnu.lost.openstack.test; import java.util.List; import javax.ws.rs.client.Entity; import org.openstack.common.client.AbstractOpenStackClient;import org.openstack.keystone.KeystoneClient;import org.openstack.keystone

hbase java sample

通过HBaseAdmin维护表(创建,删除表) import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.

solrcloud sample

在solrcloud出来之前,如果通过solrj连接solrserver,需要程序自己实现一致性hash.新版本的solr支持cloud的部署方式,可以自动实现lb和sharding的功能(通过CloudSolrServer类连接cloud),可以用下面代码做测试需要的jar包如下: apache-solr-solrj.jar apache-solr-core.jar zookeeper.jar    commons-logging.jar  apache-logging-log4j.jar 

如何将经纬度利用Google Map API显示C# VS2005 Sample Code

原文 如何将经纬度利用Google Map API显示C# VS2005 Sample Code 日前写了一篇如何用GPS抓取目前所在,并回传至资料库储存,这篇将会利用这些回报的资料,将它显示在地图上,这个做法有两种,最简单的就是直接传值到Google Maps上. 举例来说,当我们知道经纬度后,只要将数据套到以下网址即可. http://maps.google.com/maps?q=25.048346%2c121.516396 在参数q=后面,就可以加上经纬度了. 25.048346是Lati

解决新建Support7Demos的sample时出现编译错误和运行报错出现的问题

右键New->Other->Android Sample Project->选择Android 4.4.2->选择Support7Demos ,finish. 会出现编译错误 解决如下: 1.把这三个文件导入到Eclipse里, 这三个是库文件,并且勾选COPY到工作空间里选项 如果没有这三个文件,就从这里下载 2.导入三个library工程后,mediarouter会无法编译,打开工程属性在anroid里将api-level改成17,添加依赖工程appcompat 3.就是将刚才

Python 对不均衡数据进行Over sample(重抽样)

需要重采样的数据文件(Libsvm format),如heart_scale +1 1:0.708333 2:1 3:1 4:-0.320755 5:-0.105023 6:-1 7:1 8:-0.419847 9:-1 10:-0.225806 12:1 13:-1 -1 1:0.583333 2:-1 3:0.333333 4:-0.603774 5:1 6:-1 7:1 8:0.358779 9:-1 10:-0.483871 12:-1 13:1 .... 重采样后的数据保存文件(Lib

Pig sample用法举例

some = sample data 0.1 遍历整个数据集,获取指定比例的行数的数据,获取的数据不确定,条数也不准确. 内部重写为filter data by random() <= 0.1 抽取100行数据 data = load 'data'; grpd = group data all; sums = foreach grpd generate COUNT(data) as c; some = sample data 100/(double)sums.c;