⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 staxthreadqueue.java

📁 Software Testing Automation Framework (STAF)的开发代码
💻 JAVA
字号:
/*****************************************************************************//* Software Testing Automation Framework (STAF)                              *//* (C) Copyright IBM Corp. 2002                                              *//*                                                                           *//* This software is licensed under the Common Public License (CPL) V1.0.     *//*****************************************************************************/package com.ibm.staf.service.stax;import java.util.LinkedList;// XXX: This thread should probably have a list of all STAXThreads being run as// well as those on the queue.  This would allow us to make sure that we don't// try to run the same STAXThread on two real threads at the same time, which// I think actually happens now.public class STAXThreadQueue{    public STAXThreadQueue(int numThreads)    {        for (int i = 0; i < numThreads; ++i)        {            QueueThread thread = new QueueThread();            fThreads.add(thread);            thread.start();        }    }    public void add(STAXThread thread)    {        synchronized (fQueue)        {            fQueue.addLast(thread);            fQueue.notify();        }    }    class QueueThread extends Thread    {        public void run()        {            STAXThread thread = null;            for (;;)            {                try                {                    synchronized (fQueue)                    {                        while (fQueue.size() == 0) fQueue.wait();                        thread = (STAXThread)fQueue.removeFirst();                    }                    thread.execute();                }                catch (InterruptedException e)                {                    // XXX: What to do?  What does this really mean?                }            }        }    }    LinkedList fQueue = new LinkedList();    LinkedList fThreads = new LinkedList();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -