`
arne3166
  • 浏览: 131096 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论
文章列表
import java.io.*; public class MethodTest { static PrintWriter out = new PrintWriter(System.out, true);//创建一个打印流 public static void main(String[] args) { FirstThread first = new FirstThread();//创建一个线程first SecondThread second = new SecondThread();//创建一个线程second first.start();//启动线程fir ...
import java.net.*; import java.io.*; public class RunnableDemo { public static void main(String args[]) { ServerSocket s = null; Socket s1; String sendString = "Hello Net World!"; OutputStream s1out; DataOutputStream dos; try { s = new ServerSocket(5432) ...

线程冲突1

class DataObject { int dataItem1; int dataItem2; DataObject() { dataItem1 = 50; dataItem2 =50; } void itemSwap() { int x = (int)( -4.999999+Math.random() * 10); dataItem1 -= x; keepBusy( 10 ); dataItem2 += x; } void test() { int sum = dataItem1 + dataItem2; Syste ...

线程冲突2

import java.io.*; class DataFile { public DataFile() { try { FileIO.writeOneString( "Hello ","zliner.txt"); }catch( FileIOException e) {} } void fileIO() { try { String str = FileIO.readOneString( "zliner.txt" ); FileIO.writeOneString( str, ...

同步线程2

class DataObject { int dataItem1; int dataItem2; DataObject() { dataItem1 = 50; dataItem2 = 50; } synchronized void itemSwap() { int x = ( int )( -4.999999 + Math.random() * 10 ); dataItem1 -= x; keepBusy( 10 ); dataItem2 += x; } synchronized void test() { int sum ...
public class HoldIntegerSynchronized { private int sharedInt=-1; private boolean writeable=true; public synchronized void setSharedInt(int val) { while(!writeable) { try { wait(); } catch(InterruptedException e) { e.printStackTrace(); } } ...
public class ConsumeInteger extends Thread { private HoldIntegerUnsynchronized cHold; public ConsumeInteger(HoldIntegerUnsynchronized h) { super("ConsumeInteger "); cHold=h; } public void run() { int val,sum=0; do { try { Thread.sleep((i ...

生产和消费

生产和消费 import java.io.*; public class WaitPandC { static int produceSpeed = 200; static int consumeSpeed = 200; public static void main(String[] args) { if(args.length > 0) { produceSpeed = Integer.parseInt(args[0]); } if(args.length > 1) { consumeSpeed = Integer.parseI ...
三个并发线程 public class ThreadBasic extends Thread { String message; ThreadBasic (String message) {//类ThreadBasic的构造函数 this.message=message; } public void run() {//实现重定义父类的run方法 // int sleeptime=(int)(Math.random()*3000); // try{ // sleep(sleeptime);//睡眠 // }catch(Interrupt ...
多线程问题 import java.io.*; public class WithThread { static PrintWriter out = new PrintWriter(System.out, true); //创建一个打印流 public static void main(String[] args) { ThreadPseudoIO pseudo = new ThreadPseudoIO(); pseudo.start(); showElapsedTime("Another task starts"); } stati ...
Java中单线程的写法 import java.io.*; public class WithoutThread { static PrintWriter out = new PrintWriter(System.out, true); public static void main(String[] args) { NoThreadPseudoIO pseudo = new NoThreadPseudoIO(); pseudo.run(); showElapsedTime("Another task starts"); } stat ...
package com.tools; import java.util.Map; import javax.wsdl.Definition; import org.apache.axis2.description.AxisService; import org.apache.axis2.tool.codegen.WSDL2JavaGenerator; import org.apache.axis2.tool.codegen.eclipse.util.WSDLPropertyReader; import org.apache.axis2.wsdl.codegen.CodeG ...
1、导入包! 服务端 2、写好一个JavaClass的例子 a、写好pojo类 User类 package com.bean; public class User { private String userName; public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; ...
今天对照着《Agile Web Development with Rails》,在cmd中输入入:...\depot> mysql depot_development <db/create.sql,提示错误:ERROR: 1045 <28000>: Access denied for user 'ODBC'@'localhost'[/email] <using password: NO>.解决方法一:运行MySQL Server Instance Configuration Wizard,在“Please set the security options”一步 ...
多线程编程技术 多线程技术资料下载。 喜欢的,可以下载了看看。
Global site tag (gtag.js) - Google Analytics