Asynchronous communication between processes through Socket (1)

xiaoxiao2021-03-06  60

The first step is written in a thread class Commthread.java

Package com.hode.thread;

/ ** * @author Tailbo childhood * / public abstract class commthread extends thread {private boolean shoprun = false

Private int SleepTime = 2000;

PRIVATE BOOLEAN ISWAIT = FALSE;

private boolean isWork = true; / ** * * / public CommThread () {// super ( "CommThread"); Thread commThread = new Thread (CommThread.this); shouldRun = true;} public CommThread (int sleepTime) {/ / super ("CommThread"); Thread Commthread = New Thread (CommThread.this); ShouldRun = true; this.sleeptime = Sleeptime;} PUBLIC VOID ThreadStart ()};

Public void run () {while (shouldRun) {Sleep (SleepTime);} catch (interruptedException e) {system.err.println ("Thread Thread1 is unexpectedly terminated.");}} (! getWait ()) {iswork = true; system.out.println ("/ n processing start"); dispose ();

IsWork = false; system.out.println ("/ n processing");} else {iswork = false; system.out.println ("Wait ... / N");}}} public void shutdown () {ShouldRun = false;

Public void setwait (boolean bool) {iswait = bool;}

Public Boolean getWait () {return iswait;}

Public Boolean getWork () {return iswork;} public abstract void dispose ();

转载请注明原文地址:https://www.9cbs.com/read-119037.html

New Post(0)