java中的terminated_Java State.TERMINATED屬性代碼示例

本文整理匯總了Java中java.lang.Thread.State.TERMINATED屬性的典型用法代碼示例。如果您正苦於以下問題:Java State.TERMINATED屬性的具體用法?Java State.TERMINATED怎麽用?Java State.TERMINATED使用的例子?那麽恭喜您, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類java.lang.Thread.State的用法示例。

在下文中一共展示了State.TERMINATED屬性的40個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。

示例1: toThreadState

​點讚 3

/** taken from sun.misc.VM

*

* Returns Thread.State for the given threadStatus

*/

private static Thread.State toThreadState(int threadStatus) {

if ((threadStatus & JVMTI_THREAD_STATE_RUNNABLE) != 0) {

return State.RUNNABLE;

} else if ((threadStatus & JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER) != 0) {

return State.BLOCKED;

} else if ((threadStatus & JVMTI_THREAD_STATE_WAITING_INDEFINITELY) != 0) {

return State.WAITING;

} else if ((threadStatus & JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT) != 0) {

return State.TIMED_WAITING;

} else if ((threadStatus & JVMTI_THREAD_STATE_TERMINATED) != 0) {

return State.TERMINATED;

} else if ((threadStatus & JVMTI_THREAD_STATE_ALIVE) == 0) {

return State.NEW;

} else {

return State.RUNNABLE;

}

}

開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,

示例2: testGC

​點讚 3

@Test

public void testGC() throws Exception {

CountDownLatch done = new CountDownLatch(1);

Scheduler scheduler = RxSchedulers.fixedSize(1);

FinalizeSupport.finalize(scheduler, done::countDown);

Wrapper worker = Wrapper.empty();

Observable.just(1)

.subscribeOn(scheduler)

.doOnNext(i -> worker.set(Thread.currentThread()))

.blockingSubscribe();

scheduler = null;

System.gc();

assertTrue(done.await(100, TimeUnit.MILLISECONDS));

assertNotNull(worker.get());

for (int i = 0; i < 20; i++) {

System.gc();

Thread.sleep(5);

if (worker.get().getState() == State.TERMINATED) {

return;

}

}

assertEquals(State.TERMINATED, worker.get().getState());

}

開發者ID:XDean,項目名稱:Java-EX,代碼行數:23,

示例3: start

​點讚 3

private void start()

{

if( _thread == null || _thread.getState() == State.TERMINATED )

{

_isTerminated = false;

_thread = new Thread( this, _algorithm.name() + "." + _tcx.getTriangulationMode() );

_thread.start();

sendEvent( TriangulationProcessEvent.Started );

}

else

{

// Triangulation already running. Terminate it so we can start a new

shutdown();

_restart = true;

}

}

開發者ID:mleoking,項目名稱:PhET,代碼行數:16,

示例4: connectionRequest

​點讚 3

public String connectionRequest() {

if (crw == null || crw.getState() == State.TERMINATED) {

try {

System.out.println("Connection request START");

HostsLocal h = Ejb.lookupHostsBean().findByHwidAndSn(hwid, sn);

// crw = new ConnectionRequestWorker(url, conreqUser, conreqPass);

crw = new ConnectionRequestWorker(h);

setLastcrres("In progress");

crw.start();

} catch (FinderException ex) {

System.out.println("FinderException: " + ex.getLocalizedMessage());

setLastcrres(ex.getLocalizedMessage());

Logger.getLogger(HostsBean.class.getName()).log(Level.SEVERE, null, ex);

}

} else {

System.out.println("Connection request no......");

}

return null;

}

開發者ID:navisidhu,項目名稱:libreacs,代碼行數:19,

示例5: trackAllocatedHashinatorBytes

​點讚 3

private static synchronized void trackAllocatedHashinatorBytes(long bytes) {

final long allocated = m_allocatedHashinatorBytes.addAndGet(bytes);

if (allocated > HASHINATOR_GC_THRESHHOLD) {

hostLogger.warn(allocated + " bytes of hashinator data has been allocated");

if (m_emergencyGCThread == null || m_emergencyGCThread.getState() == State.TERMINATED) {

m_emergencyGCThread = new Thread(new Runnable() {

@Override

public void run() {

hostLogger.warn("Invoking System.gc() to recoup hashinator bytes");

System.gc();

try {

Thread.sleep(2000);

} catch (InterruptedException e) {}

hostLogger.info(m_allocatedHashinatorBytes.get() + " bytes of hashinator allocated after GC");

}

}, "Hashinator GC thread");

m_emergencyGCThread.start();

}

}

}

開發者ID:anhnv-3991,項目名稱:VoltDB,代碼行數:20,

示例6: start

​點讚 3

private void start()

{

if( _thread == null || _thread.getState() == State.TERMINATED )

{

_isTerminated = false;

_thread = new Thread( this, _algorithm.name() + "." + _tcx.getTriangulationMode() );

_thread.start();

sendEvent( TriangulationProcessEvent.Started );

}

else

{

// Triangulation already running. Terminate it so we can start a new

shutdown();

_restart = true;

}

}

開發者ID:lyrachord,項目名稱:FX3DAndroid,代碼行數:16,

示例7: startCountDownToExecution

​點讚 3

/**

* Call to start or reset a count down to execution of the current state's

* command.

*/

private void startCountDownToExecution() {

try {

countDownSemaphore.acquire();

if (countDownThread == null

|| countDownThread.getState() == State.TERMINATED) {

countDownThread = new Thread(countDownRunnable);

countDownThread.start();

} else {

timeToExecution = BTN_PRESS_INTERVAL;

}

} catch (Exception e) {

Log.e(TAG, e.toString());

} finally {

countDownSemaphore.release();

}

}

開發者ID:mbabic,項目名稱:HeadphoneController,代碼行數:25,

示例8: start

​點讚 3

public void start(VideoGridFragment videoGridFragment) {

if (mLibVlc == null) {

try {

mLibVlc = VLCInstance.getLibVlcInstance();

} catch (LibVlcException e) {

Log.e(TAG, "Can't obtain libvlc instance");

e.printStackTrace();

return;

}

}

isStopping = false;

if (mThread == null || mThread.getState() == State.TERMINATED) {

mVideoGridFragment = videoGridFragment;

mThread = new Thread(this);

mThread.start();

}

}

開發者ID:smyhvae,項目名稱:VlcTest,代碼行數:18,

示例9: currentThreads

​點讚 3

public static List currentThreads() {

List threads = Lists.newArrayList();

for (Thread thread : Thread.getAllStackTraces().keySet()) {

// DestroyJavaVM is a JVM thread that appears sporadically, easier to just filter it out

//

// AWT-AppKit is a JVM thread on OS X that appears during webdriver tests

//

// "process reaper" are JVM threads on linux that monitors subprocesses, these use a

// thread pool in jdk7 and so the threads stay around in the pool even after the

// subprocess ends, they show up here when mixing local container and javaagent

// container tests since javaagent container tests create subprocesses and then local

// container tests check for rogue threads and find these

if (thread.getState() != State.TERMINATED

&& !thread.getName().equals("DestroyJavaVM")

&& !thread.getName().equals("AWT-AppKit")

&& !thread.getName().equals("process reaper")) {

threads.add(thread);

}

}

return threads;

}

開發者ID:glowroot,項目名稱:glowroot,代碼行數:21,

示例10: start

​點讚 3

public void start(VideoGridFragment videoGridFragment) {

if (mLibVlc == null) {

try {

mLibVlc = Util.getLibVlcInstance();

} catch (LibVlcException e) {

Log.e(TAG, "Can't obtain libvlc instance");

e.printStackTrace();

return;

}

}

isStopping = false;

if (mThread == null || mThread.getState() == State.TERMINATED) {

mVideoGridFragment = videoGridFragment;

mThread = new Thread(this);

mThread.start();

}

}

開發者ID:KlepikovMD,項目名稱:popcorntime-android-kitkat,代碼行數:18,

示例11: connectionRequest

​點讚 3

public String connectionRequest() {

if (crw == null || crw.getState() == State.TERMINATED) {

try {

System.out.println("Connection request START");

HostsLocal h = Ejb.lookupHostsBean().findByHwidAndSn(hwid, sn);

// crw = new ConnectionRequestWorker(url, conreqUser, conreqPass);

crw = new ConnectionRequestWorker(h);

crw.start();

} catch (FinderException ex) {

Logger.getLogger(HostsBean.class.getName()).log(Level.SEVERE, null, ex);

}

} else {

System.out.println("Connection request no......");

}

return null;

}

開發者ID:ethanpeng,項目名稱:openacs,代碼行數:16,

示例12: initialize

​點讚 3

@Override

protected ConcurrentEnvironment initialize(Thread key, UncaughtExceptionHandler params) {

if (key.getState() == State.TERMINATED) {

//send an exception...

params.uncaughtException(key, new ThreadDeath());

}

if (key.isInterrupted()) {

params.uncaughtException(key, new InterruptedException());

}

X_Log.info(ConcurrencyServiceAbstract.class, "Initializing Concurrent Environment", key);

final ConcurrentEnvironment inited = initializeEnvironment(key, params);

inited.getThreads().forEach(t->

environments.put(new AbstractPair<>(t, params), inited)

);

return inited;

}

開發者ID:WeTheInternet,項目名稱:xapi,代碼行數:16,

示例13: isSaturated

​點讚 2

protected boolean isSaturated() {

if (getPoolSize() <= 3) {

return DEBUG;

}

int corePoolSize = getCorePoolSize();

int i = CountedTask.mNumRunning.get();

int size = mThreads.size();

if (i < corePoolSize || i < size) {

return true;

}

boolean z;

synchronized (mThreads) {

Iterator it = mThreads.iterator();

size = 0;

while (it.hasNext()) {

State state = it.next().getState();

if (state == State.RUNNABLE || state == State.NEW) {

i = size + 1;

} else {

if (state == State.TERMINATED) {

it.remove();

}

i = size;

}

size = i;

}

}

z = size >= corePoolSize;

return z;

}

開發者ID:bunnyblue,項目名稱:ACDD,代碼行數:30,

示例14: isConnected

​點讚 2

/**

* Returns whether the {@link com.hackathon.continuum.ddmlib.AndroidDebugBridge} object is still connected to the adb daemon.

*/

public boolean isConnected() {

MonitorThread monitorThread = MonitorThread.getInstance();

if (mDeviceMonitor != null && monitorThread != null) {

return mDeviceMonitor.isMonitoring() && monitorThread.getState() != State.TERMINATED;

}

return false;

}

開發者ID:ironmanMA,項目名稱:continuum,代碼行數:10,

示例15: start

​點讚 2

private void start() {

if (_thread == null || _thread.getState() == State.TERMINATED) {

_isTerminated = false;

_thread = new Thread(this, _algorithm.name() + "." + _tcx.getTriangulationMode());

_thread.start();

sendEvent(TriangulationProcessEvent.Started);

} else {

// Triangulation already running. Terminate it so we can start a new

shutdown();

_restart = true;

}

}

開發者ID:perunlabs,項目名稱:jsolid,代碼行數:12,

示例16: allowThreadsToFinish

​點讚 2

/**

* Will lock Thread accessible when called from Thread via repetitive sleep

* calls until the passed in threads are terminated. Generally used to keep

* the test exec thread alive while the other threads are still working.

*

* @param threads

* @throws InterruptedException

*/

public static void allowThreadsToFinish(final Thread[] threads)

throws InterruptedException {

boolean threadsDone = false;

while(!threadsDone){

threadsDone = true;

for(Thread thread : threads){

if(thread.getState() != State.TERMINATED){

Thread.sleep(10);

threadsDone = false;

}

}

}

}

開發者ID:nkalupahana,項目名稱:completed-koans,代碼行數:21,

示例17: getCurrentValue

​點讚 2

public long getCurrentValue() {

if (getState() == State.TERMINATED) {

return 101;

} else {

return (new Date().getTime() - startTime) * 100 / timeout;

}

}

開發者ID:navisidhu,項目名稱:libreacs,代碼行數:7,

示例18: getInProgress

​點讚 2

public boolean getInProgress() {

boolean res;

if (crw == null) {

res = false;

} else {

res = (crw.getState() != State.TERMINATED);

//System.out.println ("GetInProgress="+res);

}

return res;

}

開發者ID:navisidhu,項目名稱:libreacs,代碼行數:10,

示例19: isConnected

​點讚 2

/**

* Returns whether the {@link AndroidDebugBridge} object is still connected to the adb daemon.

*/

public boolean isConnected() {

MonitorThread monitorThread = MonitorThread.getInstance();

if (mDeviceMonitor != null && monitorThread != null) {

return mDeviceMonitor.isMonitoring() && monitorThread.getState() != State.TERMINATED;

}

return false;

}

開發者ID:rock3r,項目名稱:framer,代碼行數:10,

示例20: write

​點讚 2

private synchronized void write(ArrayList list){

if(readstream1!=null){

if(readstream1.getState()==State.TERMINATED){throw new RuntimeException("Writing to a terminated thread.");}

readstream1.addList(list);

}

if(readstream2!=null){

if(readstream1.getState()==State.TERMINATED){throw new RuntimeException("Writing to a terminated thread.");}

readstream2.addList(list);

}

}

開發者ID:abiswas-odu,項目名稱:Disco,代碼行數:10,

示例21: loadMediaItems

​點讚 2

public void loadMediaItems() {

if (mLoadingThread == null || mLoadingThread.getState() == State.TERMINATED) {

isStopping = false;

Util.actionScanStart();

mLoadingThread = new Thread(new GetMediaItemsRunnable());

mLoadingThread.start();

}

}

開發者ID:jiaZengShen,項目名稱:vlc_android_win,代碼行數:8,

示例22: isWorking

​點讚 2

public boolean isWorking() {

if (mLoadingThread != null &&

mLoadingThread.isAlive() &&

mLoadingThread.getState() != State.TERMINATED &&

mLoadingThread.getState() != State.NEW)

return true;

return false;

}

開發者ID:jiaZengShen,項目名稱:vlc_android_win,代碼行數:8,

示例23: start

​點讚 2

public void start(IVideoBrowser videoBrowser) {

mLibVlc = VLCInstance.get();

isStopping = false;

if (mThread == null || mThread.getState() == State.TERMINATED) {

mVideoBrowser = new WeakReference(videoBrowser);

mThread = new Thread(this);

mThread.start();

}

}

開發者ID:jiaZengShen,項目名稱:vlc_android_win,代碼行數:10,

示例24: scanMediaItems

​點讚 2

public void scanMediaItems() {

if (mLoadingThread == null || mLoadingThread.getState() == State.TERMINATED) {

isStopping = false;

Util.actionScanStart();

mLoadingThread = new Thread(new GetMediaItemsRunnable());

mLoadingThread.start();

}

}

開發者ID:hanhailong,項目名稱:VCL-Android,代碼行數:8,

示例25: start

​點讚 2

public void start(IVideoBrowser videoBrowser) {

isStopping = false;

if (mThread == null || mThread.getState() == State.TERMINATED) {

mVideoBrowser = new WeakReference(videoBrowser);

mThread = new Thread(this);

mThread.start();

}

}

開發者ID:hanhailong,項目名稱:VCL-Android,代碼行數:8,

示例26: loadMediaItems

​點讚 2

public void loadMediaItems() {

if (mLoadingThread == null || mLoadingThread.getState() == State.TERMINATED) {

isStopping = false;

Util.actionScanStart();

// 開啟線程進行加載》GetMediaItemsRunnable()

mLoadingThread = new Thread(new GetMediaItemsRunnable());

mLoadingThread.start();

}

}

開發者ID:xuie0000,項目名稱:vlc-android,代碼行數:9,

示例27: loadMediaItems

​點讚 2

public void loadMediaItems() {

if (mLoadingThread == null || mLoadingThread.getState() == State.TERMINATED) {

isStopping = false;

VideoGridFragment.actionScanStart();

mLoadingThread = new Thread(new GetMediaItemsRunnable());

mLoadingThread.start();

}

}

開發者ID:smyhvae,項目名稱:VlcTest,代碼行數:8,

示例28: loadMediaItems

​點讚 2

public void loadMediaItems(Context context) {

if (mLoadingThread == null || mLoadingThread.getState() == State.TERMINATED) {

isStopping = false;

VideoGridFragment.actionScanStart(context.getApplicationContext());

mLoadingThread = new Thread(new GetMediaItemsRunnable(context.getApplicationContext()));

mLoadingThread.start();

}

}

開發者ID:KlepikovMD,項目名稱:popcorntime-android-kitkat,代碼行數:8,

示例29: testGuid

​點讚 2

/**

* Tests the improvement added by using a SecureRandom pool when generating GUID's

*/

public void testGuid()

{

// warm-up (to pre-init the secureRandomArray)

GUID.generate();

List threads = new ArrayList<>();

int n = 30;

for (int i = 0; i < n; i++)

{

Thread thread = new Thread(new GuidRunner());

threads.add(thread);

thread.start();

}

Set blocked = new HashSet();

Set terminated = new HashSet();

int maxItemsBlocked = 0;

while (terminated.size() != n)

{

for (Thread current : threads)

{

State state = current.getState();

String name = current.getName();

if (state == State.BLOCKED)

{

if (!blocked.contains(name))

{

blocked.add(name);

maxItemsBlocked = blocked.size() > maxItemsBlocked ? blocked.size() : maxItemsBlocked;

}

}

else // not BLOCKED, eg. RUNNABLE, TERMINATED, ...

{

blocked.remove(name);

if (state == State.TERMINATED && !terminated.contains(name))

{

terminated.add(name);

}

}

}

}

//worst case scenario : max number of threads blocked at a moment = number of threads - 2 ( usually ~5 for 30 threads)

//the implementation without RandomSecure pool reaches constantly (number of threads - 1) max blocked threads

Assert.assertTrue("Exceeded number of blocked threads : " + maxItemsBlocked, maxItemsBlocked < n-2);

}

開發者ID:Alfresco,項目名稱:alfresco-core,代碼行數:53,

示例30: main

​點讚 2

public static void main(String[] args) {

// 線程優先級信息

System.out.printf("Minimum Priority: %s\n", Thread.MIN_PRIORITY);

System.out.printf("Normal Priority: %s\n", Thread.NORM_PRIORITY);

System.out.printf("Maximum Priority: %s\n", Thread.MAX_PRIORITY);

Thread threads[];

Thread.State status[];

// 開 10 個線程,5 個最高優先級,5 個最低優先級

threads = new Thread[10];

status = new Thread.State[10];

for (int i = 0; i < 10; i++) {

threads[i] = new Thread(new Calculator());

if ((i % 2) == 0) {

threads[i].setPriority(Thread.MAX_PRIORITY);

} else {

threads[i].setPriority(Thread.MIN_PRIORITY);

}

threads[i].setName("My Thread " + i);

}

// 記錄線程的狀態

for (int i = 0; i < 10; i++) {

System.out.println("Main : Status of Thread " + i + " : " + threads[i].getState());

status[i] = threads[i].getState();

}

// 開始線程

for (int i = 0; i < 10; i++) {

threads[i].start();

}

// 當線程狀態改變,輸出相應信息

boolean finish = false;

while (!finish) {

for (int i = 0; i < 10; i++) {

if (threads[i].getState() != status[i]) {

writeThreadInfo(threads[i], status[i]);

status[i] = threads[i].getState();

}

}

finish = true;

for (int i = 0; i < 10; i++) {

// 當所有線程都終止

finish = finish && (threads[i].getState() == State.TERMINATED);

}

}

}

開發者ID:firery,項目名稱:java-concurrency-cheatsheet,代碼行數:52,

示例31: main

​點讚 2

/**

* Main method of the example

*

* @param args

*/

public static void main(String[] args) {

// Thread priority infomation

System.out.printf("Minimum Priority: %s\n", Thread.MIN_PRIORITY);

System.out.printf("Normal Priority: %s\n", Thread.NORM_PRIORITY);

System.out.printf("Maximun Priority: %s\n", Thread.MAX_PRIORITY);

Thread threads[];

Thread.State status[];

// Launch 10 threads to do the operation, 5 with the max

// priority, 5 with the min

threads = new Thread[10];

status = new Thread.State[10];

for (int i = 0; i < 10; i++) {

threads[i] = new Thread(new Calculator());

if ((i % 2) == 0) {

threads[i].setPriority(Thread.MAX_PRIORITY);

} else {

threads[i].setPriority(Thread.MIN_PRIORITY);

}

threads[i].setName("My Thread " + i);

}

// Wait for the finalization of the threads. Meanwhile,

// write the status of those threads in a file

try (FileWriter file = new FileWriter(".\\data\\log.txt"); PrintWriter pw = new PrintWriter(file);) {

// Write the status of the threads

for (int i = 0; i < 10; i++) {

pw.println("Main : Status of Thread " + i + " : " + threads[i].getState());

status[i] = threads[i].getState();

}

// Start the ten threads

for (int i = 0; i < 10; i++) {

threads[i].start();

}

// Wait for the finalization of the threads. We save the status of

// the threads and only write the status if it changes.

boolean finish = false;

while (!finish) {

for (int i = 0; i < 10; i++) {

if (threads[i].getState() != status[i]) {

writeThreadInfo(pw, threads[i], status[i]);

status[i] = threads[i].getState();

}

}

finish = true;

for (int i = 0; i < 10; i++) {

finish = finish && (threads[i].getState() == State.TERMINATED);

}

}

} catch (IOException e) {

e.printStackTrace();

}

}

開發者ID:PacktPublishing,項目名稱:Java-9-Concurrency-Cookbook-Second-Edition,代碼行數:65,

示例32: calculatorMain

​點讚 2

/**

* http://ifeve.com/thread-management-2/

* http://ifeve.com/thread-management-3/

*

* @see Calculator

*/

public static void calculatorMain() {

Thread[] threads = new Thread[THREAD_SIZE];

State[] status = new State[THREAD_SIZE];

for (int i = 0; i < THREAD_SIZE; i++) {

threads[i] = new Thread(new Calculator(i));

if (i % 2 == 0) {

threads[i].setPriority(Thread.MAX_PRIORITY);

} else {

threads[i].setPriority(Thread.MIN_PRIORITY);

}

threads[i].setName("Thread " + i);

}

try (FileWriter fileWriter = new FileWriter(".\\data\\log.txt"); PrintWriter printWriter = new PrintWriter(fileWriter);) {

for (int i = 0; i < THREAD_SIZE; i++) {

printWriter.println("Main : Status of Thread " + i + " : " + threads[i].getState());

status[i] = threads[i].getState();

}

printWriter.println();

for (int i = 0; i < THREAD_SIZE; i++) {

threads[i].start();

}

boolean finish = false;

while (!finish) {

for (int i = 0; i < THREAD_SIZE; i++) {

if (threads[i].getState() != status[i]) {

writeThreadInfo(printWriter, threads[i], status[i]);

status[i] = threads[i].getState();

}

}

finish = true;

for (int i = 0; i < THREAD_SIZE; i++) {

finish = finish && (threads[i].getState() == State.TERMINATED);

}

}

} catch (IOException e) {

e.printStackTrace();

}

}

開發者ID:Saisimon,項目名稱:tip,代碼行數:49,

示例33: shutDownThreads

​點讚 2

static final int shutDownThreads(AbstractMapThread[] mtts, boolean force){

int broken=0;

long millis=force ? 500 : 8000;

for(int i=0; i

AbstractMapThread mtt=mtts[i];

if(mtt==null){broken++;}

else{

synchronized(mtt){

while(mtt.working()){

State st=mtt.getState();

if(st==State.TERMINATED){

if(mtt.working()){

broken++;

break;

}

}

try {

mtt.wait(millis);

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

if(force && mtt.working()){

mtt.interrupt();

broken++;

break;

}

}

}

if(i==0){

sysout.print("Detecting finished threads: 0");

}else{

sysout.print(", "+i);

}

}

}

if(broken>0){

System.err.println("\n\n**************************************************************************\n" +

"Warning! "+broken+" mapping thread"+(broken==1 ? "" : "s")+" did not terminate normally.\n" +

"Check the error log; the output may be corrupt or incomplete.\n" +

"Please submit the full stderr output as a bug report, not just this message.\n" +

"**************************************************************************\n\n");

}

return broken;

}

開發者ID:abiswas-odu,項目名稱:Disco,代碼行數:46,

示例34: makeIndex

​點讚 2

public static Block[] makeIndex(final int genome, int minChrom, int maxChrom, int k, int CHROMBITS,

int MAX_ALLOWED_CHROM_INDEX, int CHROM_MASK_LOW, int CHROM_MASK_HIGH, int SITE_MASK, int SHIFT_LENGTH, boolean WRITE, boolean DISK_INVALID, Block[] index){

Timer t=new Timer();

MAX_CONCURRENT_BLOCKS=(Data.WINDOWS ? 1 : Tools.max(1, Shared.threads()/4));

minChrom=Tools.max(1, minChrom);

if(genome>=0 && Data.GENOME_BUILD!=genome){

Data.setGenome(genome);

maxChrom=Tools.min(Data.numChroms, maxChrom);

}

assert(minChrom<=maxChrom);

if(index==null){index=new Block[maxChrom+1];}

ArrayList list=new ArrayList();

for(int i=1; i<=maxChrom;){

if(i>=minChrom){

int a=minChrom(i, minChrom, CHROM_MASK_HIGH);

int b=maxChrom(i, minChrom, maxChrom, CHROM_MASK_LOW);

assert(b>=i);

BlockMaker idm=new BlockMaker(a, b, k, CHROMBITS, MAX_ALLOWED_CHROM_INDEX, CHROM_MASK_LOW, CHROM_MASK_HIGH, SITE_MASK, SHIFT_LENGTH, WRITE, DISK_INVALID, index);

list.add(idm);

incrementActiveBlocks(1);

idm.start();

while(idm.getState()==State.NEW){}//wait

i=b+1;

}else{i++;}

}

for(BlockMaker cm : list){

while(cm.getState()!=State.TERMINATED){

try {

cm.join();

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}

t.stop();

//Data.sysout.println("Index gen time: \t"+t);

return index;

}

開發者ID:abiswas-odu,項目名稱:Disco,代碼行數:51,

示例35: makeIndex

​點讚 2

public static Block[] makeIndex(final int genome, int minChrom, int maxChrom, int k, int CHROMBITS,

int MAX_ALLOWED_CHROM_INDEX, int CHROM_MASK_LOW, int CHROM_MASK_HIGH, int SITE_MASK, int SHIFT_LENGTH,

boolean WRITE, boolean DISK_INVALID, Block[] index){

Timer t=new Timer();

MAX_CONCURRENT_BLOCKS=(Shared.LOW_MEMORY ? 1 : (Data.WINDOWS ? (WRITE ? 1 : Tools.max(1, Shared.threads()/4)) : Tools.max(1, Shared.threads()/4)));

minChrom=Tools.max(1, minChrom);

if(genome>=0 && Data.GENOME_BUILD!=genome){

Data.setGenome(genome);

maxChrom=Tools.min(Data.numChroms, maxChrom);

}

assert(minChrom<=maxChrom);

if(index==null){index=new Block[maxChrom+1];}

ArrayList list=new ArrayList();

for(int i=1; i<=maxChrom;){

if(i>=minChrom){

int a=minChrom(i, minChrom, CHROM_MASK_HIGH);

int b=maxChrom(i, minChrom, maxChrom, CHROM_MASK_LOW);

assert(b>=i);

BlockMaker idm=new BlockMaker(a, b, k, CHROMBITS, MAX_ALLOWED_CHROM_INDEX, CHROM_MASK_LOW, CHROM_MASK_HIGH, SITE_MASK, SHIFT_LENGTH, WRITE, DISK_INVALID, index);

list.add(idm);

incrementActiveBlocks(1);

idm.start();

while(idm.getState()==State.NEW){}//wait

i=b+1;

}else{i++;}

}

for(BlockMaker cm : list){

while(cm.getState()!=State.TERMINATED){

try {

cm.join();

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}

t.stop();

//Data.sysout.println("Index gen time: \t"+t);

return index;

}

開發者ID:abiswas-odu,項目名稱:Disco,代碼行數:52,

示例36: actionPerformed

​點讚 2

public void actionPerformed(ActionEvent e) {

switch (e.getActionCommand()) {

case "��":

//���ļ�,���b.load����ֵ

error("");

loadFile();

btnRun.setText("����");

break;

case "ֹͣ":

exec.interrupt();

try {

exec.join();

} catch (InterruptedException e1) {

e1.printStackTrace();

}

break;

case "����": //��������ͣ��������basic���б�־������������룬������

if (exec == null || exec.getState() == State.TERMINATED)

return;

if (!exec.isAlive()) {

exec.start();

btnLoad.setText("ֹͣ");

} else

b.cont();

btnRun.setText("��ͣ");

error("");

break;

case "��ͣ":

b.pause();

btnRun.setText("����");

break;

case "����":

if (vtShow) {

remove(jvt);

scr.requestFocus(); //����ת�Ƶ���Ļ�������޷���ⰴ��

} else {

GridBagConstraints cs = new GridBagConstraints();

cs.gridy = 4;

cs.gridwidth = 3;

add(jvt, cs);

}

vtShow = !vtShow;

pack();

break;

case "��ͼ":

screenshot();

break;

case "ͼ�����":

if (imd == null)

imd = new ImageDialog(this);

break;

}

}

開發者ID:arucil,項目名稱:gvbasic-simulator4j,代碼行數:53,

示例37: startDaGuaiThread

​點讚 2

/**

* 開啟打怪線程

* 自動檢索線程是否開啟,若沒開啟,則全部重新開啟。若開啟後沒有執行完畢,則繼續使用

*/

public void startDaGuaiThread(){

Command.mainThread=true;//線程運行狀態開啟

try {

if(Command.logThread.getState()==State.TERMINATED){

Command.logThread=null;

Command.logThread=new LogThread();

Command.logThread.start();

new Func.File().log("日誌線程啟動");

}

if(Command.daGuaiThread.getState()==State.TERMINATED){

Command.daGuaiThread=null;

Command.daGuaiThread=new DaGuaiThread();

Command.daGuaiThread.start();

new Func.File().log("打怪主線程啟動");

}

if(Command.systemThread.getState()==State.TERMINATED){

Command.systemThread=null;

Command.systemThread=new SystemThread();

Command.systemThread.start();

new Func.File().log("係統線程啟動");

}

} catch (Exception e) {//捕獲異常,可能是線程未初始化,進行初始化線程並開啟

if(e.getMessage()!=null){

new Func.File().log("線程初始化開啟");

}

Command.daGuaiThread=new DaGuaiThread();

Command.logThread=new LogThread();

Command.systemThread=new SystemThread();

Command.daGuaiThread.start();

new Func.File().log("打怪主線程啟動");

Command.logThread.start();

new Func.File().log("日誌線程啟動");

Command.systemThread.start();

new Func.File().log("係統線程啟動");

}

Command.daGuaiThread.setPriority(1);//打怪主線程優先級最低

Command.logThread.setPriority(1);//日誌線程,最低

Command.systemThread.setPriority(8);//係統線程最高

Command.daGuaiThread.setName("打怪主線程");

Command.logThread.setName("日誌線程");

Command.systemThread.setName("係統線程");

}

開發者ID:xnx3,項目名稱:xunxian,代碼行數:51,

示例38: startSettledOpenGuThread

​點讚 2

/**

* 定點開鼓

*/

public void startSettledOpenGuThread(){

Command.mainThread=true;//線程運行狀態開啟

try {

if(Command.logThread.getState()==State.TERMINATED){

Command.logThread=null;

Command.logThread=new LogThread();

Command.logThread.start();

new Func.File().log("日誌線程啟動");

}

if(Command.settledOpenThread.getState()==State.TERMINATED){

Command.settledOpenThread=null;

Command.settledOpenThread=new SettledOpenThread();

Command.settledOpenThread.start();

new Func.File().log("定點掃描鼓主線程啟動");

}

if(Command.systemThread.getState()==State.TERMINATED){

Command.systemThread=null;

Command.systemThread=new SystemThread();

Command.systemThread.start();

new Func.File().log("係統線程啟動");

}

} catch (Exception e) {//捕獲異常,可能是線程未初始化,進行初始化線程並開啟

if(e.getMessage()!=null){

new Func.File().log("線程初始化開啟");

}

Command.settledOpenThread=new SettledOpenThread();

Command.logThread=new LogThread();

Command.systemThread=new SystemThread();

Command.settledOpenThread.start();

new Func.File().log("打怪主線程啟動");

Command.logThread.start();

new Func.File().log("日誌線程啟動");

Command.systemThread.start();

new Func.File().log("係統線程啟動");

}

Command.settledOpenThread.setPriority(1);//打怪主線程優先級最低

Command.logThread.setPriority(1);//日誌線程,最低

Command.systemThread.setPriority(8);//係統線程最高

Command.settledOpenThread.setName("定點開鼓主線程");

Command.logThread.setName("日誌線程");

Command.systemThread.setName("係統線程");

}

開發者ID:xnx3,項目名稱:xunxian,代碼行數:50,

示例39: startSaoHuoThread

​點讚 2

/**

* 自動掃貨

*/

public void startSaoHuoThread(){

Command.mainThread=true;

try{

if(Command.saoHuoThread.getState()==State.TERMINATED){

Command.saoHuoThread=null;

Command.saoHuoThread=new SaoHuoThread();

Command.saoHuoThread.start();

new Func.File().log("掃貨主線程啟動");

}

if(Command.logThread.getState()==State.TERMINATED){

Command.logThread=null;

Command.logThread=new LogThread();

Command.logThread.start();

new Func.File().log("日誌線程啟動");

}

if(Command.systemThread.getState()==State.TERMINATED){

Command.systemThread=null;

Command.systemThread=new SystemThread();

Command.systemThread.start();

new Func.File().log("係統線程啟動");

}

}catch (Exception e) {

if(e.getMessage()!=null){

new Func.File().log("掃貨線程開啟異常捕獲:"+e.getMessage());

}

Command.saoHuoThread=new SaoHuoThread();

Command.saoHuoThread.start();

new Func.File().log("掃貨主線程啟動");

Command.logThread=new LogThread();

Command.logThread.start();

new Func.File().log("日誌線程啟動");

Command.systemThread=new SystemThread();

Command.systemThread.start();

new Func.File().log("係統線程啟動");

}

Command.saoHuoThread.setName("掃貨主線程");

Command.saoHuoThread.setPriority(7);//監控優先級高!

Command.logThread.setName("日誌線程");

Command.logThread.setPriority(1);//日誌線程最低

Command.systemThread.setName("係統線程");

Command.systemThread.setPriority(8);//係統線程優先級最高

}

開發者ID:xnx3,項目名稱:xunxian,代碼行數:53,

示例40: waitForChild

​點讚 2

protected void waitForChild(int maxIdleTime) {

while (getThreadsCount() > 0) {

try {

synchronized (this) {

wait(5000);

}

boolean masterAbort = isAborted();

// Remove terminated thread

rwl.w.lock();

try {

synchronized (threads) {

boolean remove = false;

Iterator it = threads.iterator();

while (it.hasNext()) {

T thread = it.next();

if (thread.getThreadState() == State.TERMINATED) {

it.remove();

remove = true;

} else if (masterAbort && thread.isIdleTimeExhausted(maxIdleTime)) {

// Force child aborting if the crawl master is

// already aborting and the thread idle time

// expired

Logging.warn("Thread aborting (time out): " + thread.getCurrentMethod());

thread.abort();

it.remove();

remove = true;

}

}

if (remove)

threadArray = null;

}

} finally {

rwl.w.unlock();

}

} catch (InterruptedException e) {

Logging.warn(e.getMessage(), e);

}

ThreadUtils.sleepMs(1000);

}

}

開發者ID:jaeksoft,項目名稱:opensearchserver,代碼行數:41,

注:本文中的java.lang.Thread.State.TERMINATED屬性示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值