亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? javaconc.html

?? Concurrent Programming in Java
?? HTML
?? 第 1 頁 / 共 3 頁
字號(hào):
  <li> <code>suspend()</code> halts a thread in a way that will continue        normally after calling <code>resume()</code>.  <li> <code>sleep()</code> and related methods      cause objects to suspend and automatically resume in a controlled      fashion, typically from within the running object itself.  <li> <code>wait()</code> (which is defined in class <code>Object</code>,       so is available to all Java objects)      causes a thread to suspend until a later <code>notifyAll</code>      or <code>notify</code> is made (nearly always within some other method of the      object invoking  the <code>wait</code>).        <li> <code>yield()</code> yields control back to the scheduler      (see below) so it can run other threads before returning to run      more of this one.</ul><p> For example, here is a different kind of message printer (an exampleof the <a href="auton.html" tppabs="http://www.foi.hr/~dpavlin/java/mirrors/g.oswego.edu/dl/pats/auton.html">autonomous loop </a> pattern) that printsits message on average about every 5 seconds forever until stopped:<pre>public class SleepingMessagePrinter extends SimpleMessagePrinter {  public SleepingMessagePrinter(String m, TextArea t) { super(m, t); }  public void run() {    for (;;) {      try {        Thread.currentThread().sleep((int)(Math.random() * 10000));      }      catch (InterruptedException e) { return; }      txt_.appendText(msg_);       txt_.repaint();      }  }}</pre><p>This can be driven from an Applet such as:<pre>public class SleepingMessageAppletV1 extends Applet {  protected TextArea txt_;  protected SleepingMessagePrinter hello_;  protected SleepingMessagePrinter goodbye_;  protected Thread ht_;  protected Thread gt_;  public SleepingMessageAppletV1() {    txt_ = new TextArea(4, 40);    txt_.setEditable(true);    hello_ = new SleepingMessagePrinter("Hello\n", txt_);    goodbye_ = new SleepingMessagePrinter("Goodbye\n", txt_);    ht_ = new Thread(hello_);    ht_.setDaemon(true);    gt_ = new Thread(goodbye_);    gt_.setDaemon(true);  }  public void init() {    setLayout(new BorderLayout());     add("South", txt_);    add("North", new Button("Stop"));  }  public void start() {    ht_.start();    gt_.start();  }  public boolean action(Event evt, Object arg) {    if ("Stop".equals(arg)) {      stop();      return true;    }    return false;  }  public void stop() {    ht_.stop();    gt_.stop();  }}</pre><p><a href="SleepingMessageAppletV1.html" tppabs="http://www.foi.hr/~dpavlin/java/mirrors/g.oswego.edu/dl/pats/SleepingMessageAppletV1.html">Run SleepingMessageAppletV1</a>.<p>Notes:<ol>  <li> The setDaemon(true) call establishes the message printers        as <em>daemon</em> threads. The only difference between        normal and daemon threads is that a java application is allowed        to shut down once there are no more normal threads, but only        daemon threads. It is usually a good idea to establish possibly        infinitely looping threads as daemons.  <li> The <code>sleep</code> method can throw <code>InterruptedException</code>        if another thread interrupts it. The only sensible thing to        do in this example is exit. </ol><h3>Scheduling and Priorities</h3>Unless you have better-than-average hardware, all of the activethreads in a Java application share the same CPU, which means thateach has to take turns executing for a while, and then being held in await queue while other threads get a chance to run, and so on.  Andeven if you have multiple CPUs, you will still probably often havemore threads than CPUs.  The scheduler that controls which threads geta chance to run uses <em>priorities</em> to decide which thread to runat any given time.  Priorities are just numbers (between<code>Thread.MIN_PRIORITY</code> and <code>Thread.MAX_PRIORITY</code>)that help control scheduling.<p> When a thread is created to perform some possibly longcomputation, it is a good idea to give it a relatively low priority sothat other threads that deal with users will run instead whenever bothare in runnable states. If you don't do this, the rest of the program(especially the UI) will seem at best sluggish, and at worst will betotally unresponsive.<p> For a real example, the <AHREF="javascript:if(confirm('http://g.oswego.edu/dl/applets/micro.html  \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address.  \n\nDo you want to open it from the server?'))window.location='http://g.oswego.edu/dl/applets/micro.html'" tppabs="http://g.oswego.edu/dl/applets/micro.html"> Microscope</A> gameis an applet that contains a slow automatic move finder. The <AHREF="javascript:if(confirm('http://g.oswego.edu/dl/classes/applets/Microscope.java  \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address.  \n\nDo you want to open it from the server?'))window.location='http://g.oswego.edu/dl/classes/applets/Microscope.java'" tppabs="http://g.oswego.edu/dl/classes/applets/Microscope.java"> code</A> setting up the move finder thread includes:<pre>  public synchronized void startTurn(Board b, Player p) {    if (!placing()) {      initialBoard = b;      initialPlayer = p;      ...      findThread = new Thread(this);      findThread.setPriority(Thread.MIN_PRIORITY);      findThread.start();    }  }</pre><p><em>Note: This has the desired effect in JDK appletviewer, butfor unknown reasons, apparently not in Netscape-2beta5. </em><p> Another, less pleasant way to control scheduling is to placefrequent <code>yield()</code> calls in the worker codeitself. <code>Yield()</code> tells the scheduler to place the currentthread in the scheduling queue to give another thread a chance to runbefore getting back to the current one. However, if the current threadhas highest priority of those waiting, the yield may cause itimmediately resume anyway. (See the <a href="auton.html" tppabs="http://www.foi.hr/~dpavlin/java/mirrors/g.oswego.edu/dl/pats/auton.html"> AutonomousLoops</a> pattern for an example.)<blockquote>(Footnote: In most examples, we don't bother showing or dealing withpriorities. However, in general, it is a good idea to explicitlyset a priority whenever starting a new thread.)</blockquote><h3>ThreadGroups</h3>Every Java thread is created within a <code>ThreadGroup</code>.By default, each new thread is created to be in the same groupas its creator. ThreadGroups nest, so one whole ThreadGroup maybe part of another.<p> Threads within a ThreadGroup share some access and controlpolicies.  For example, it is not legal to <code>stop</code> a threadthat is not in your group. This makes sure that, for example, a randomApplet doesn't kill the main Java screen display update loop thread.<p>The <code>ThreadGroup</code> class has some methods similar to thosein class <code>Thread</code>, but apply them to groups ofthreads instead of individuals.<p>Among the few common uses of ThreadGroups is to shut down all of thethreads associated with some task by calling<code>getThreadGroup().stop()</code>.<h2><a name="secSynch"></a>Synchronization</h2>So far, we've discussed only some variants of designs in which oneobject put a thread in motion, and then didn't have any interestingfurther interaction with it except perhaps to stop it. When objects inspawned threads run independently of <em>all</em> other activities andobjects in a program, you don't have to worry about the details ofasynchronous object interaction. But this is hardly ever the case.Even, or especially, when objects in different threads do not directlycommunicate, there is still the potential for indirect interactionwhen one object has methods invoked from those running in more thanone thread.  For a simple example, two threads may both be setting andretrieving elements from the same data structure.  What if an elementis only partially set by one object when it is accessed by the other?<p>Java provides a few general mechanisms for dealing with these issues, althoughyou have to work out the details on a case-by-case basis.<p>The general idea of programming cooperating asynchronous objects is that<br><blockquote><strong> Each object must protect ITSELF from any interference thatcould occur when participating in multiple threads.  </strong></blockquote><p> The main Java construct that helps ensure this is the<code>synchronized</code> keyword. Any method marked as synchronizedis always executed in its entirety (unless explicitly suspended; forexample via a <a href="#secGuards"><code>wait</code></a>) before theobject is allowed to perform any other synchronized method calledfrom any other thread. <p> For example, consider an Applet Registry (somewhat like the existing<code>java.applet.AppletContext</code> class) where Applets can registerthemselves so that others can communicate with them.<p> We need to digress for a moment to figure out how to go aboutbuilding a registry.  To work at all, a registry must be accessiblefrom all Applets.  Since an Applet newly fired up from an HTML pagecould not know of the reference of an already-constucted registry, itwon't work to use normal Java objects. But there turns out to be aneasy way to do it using a variant of the <em>Facade</em> designpattern that uses an underlying <em>Singleton</em> (see the <AHREF="javascript:if(confirm('http://st-www.cs.uiuc.edu/users/patterns/Books.html  \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address.  \n\nDo you want to open it from the server?'))window.location='http://st-www.cs.uiuc.edu/users/patterns/Books.html'" tppabs="http://st-www.cs.uiuc.edu/users/patterns/Books.html"> DesignPatterns</A> book). We can build a <em>class</em> with all staticmethods, each of which hands off all functionality to a single normalJava helper object that does the real work. Since static methods needonly have the class name (not an object reference) to work, all iswell.<p>So the outwardly accessible Registry object is defined as follows:<pre>public class AppletRegistry extends Applet {  static private AppletRegistryObject theRegistry =     new AppletRegistryObject();  public AppletRegistry() { }  public static void add(String nm, Applet app) { theRegistry.add(nm, app);  }  public static Applet get(String nm)         { return theRegistry.get(nm);  }  public static int entries()                { return theRegistry.entries(); }  public static String nth(int i)               { return theRegistry.nth(i); }  public static void remove(String nm)             { theRegistry.remove(nm); }}</pre><p><blockquote> (Footnote: This strategy could be recast as a moregeneral design pattern. For example, you could use the same scheme toset up a <em>ControlPanel</em> for multiple Applets. Unlike thosebased on the builtin <code>java.applet.AppletContext</code>, theapplets being controlled would not even need to be spawned from thesame HTML page.)  </blockquote><p> The actual implementation class <code>AppletRegistryObject</code>here uses the simplest, barest data types (a stripped down variant ofa <a href="synchDesign.html" tppabs="http://www.foi.hr/~dpavlin/java/mirrors/g.oswego.edu/dl/pats/synchDesign.html">BoundedBuffer</a>) just to make thesynchronization issues clearer. The Registry is implemented using twofixed-sized arrays, one holding the names the objects will be accessedby, and the other the corresponding objects.  We need to have methodsto register an applet by name, to access one by name, to delete anentry, and allow simple indexed access to support traversal. Surely,an AppletRegistry object should only be doing one of these things at atime, so each of these should be marked as synchronized:<blockquote><strong> Note: The following code is functional but onlyillustrative.  If you build your own registry, please use moresensible data structures!  </strong></blockquote><pre>class AppletRegistryObjectV0 {  static private final int CAPACITY = 3; // for demo purposes  private String names[] = new String[CAPACITY];  private Applet apps[]  = new Applet[CAPACITY];  private int len = 0;

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日日夜夜精品视频免费| 国产成人精品亚洲777人妖| 日本亚洲三级在线| 蜜桃av噜噜一区二区三区小说| 日韩精品三区四区| 国产一区二区三区四区五区美女| 国产成人免费在线观看| 99久久er热在这里只有精品66| 色激情天天射综合网| 欧美一区二区三区视频在线| 久久综合国产精品| 国产精品久久久久久久久免费樱桃 | 久久精品日韩一区二区三区| 日韩码欧中文字| 久久精品国产秦先生| 成人av资源下载| 制服丝袜激情欧洲亚洲| 国产女人18毛片水真多成人如厕| 夜夜亚洲天天久久| 国产成人精品三级| 欧美一区二区三区成人| 亚洲美女视频在线| 国产高清久久久久| 欧美第一区第二区| 亚洲自拍偷拍网站| 成人白浆超碰人人人人| 精品对白一区国产伦| 亚洲一区二区黄色| 99精品一区二区| 久久先锋影音av鲁色资源| 亚洲成年人网站在线观看| 99久久婷婷国产综合精品电影| 精品国产91洋老外米糕| 日韩av中文字幕一区二区| 欧美性xxxxxxxx| 亚洲精品久久久蜜桃| 风流少妇一区二区| 国产日韩欧美高清| 国产伦精品一区二区三区视频青涩 | 蜜臀av一级做a爰片久久| 日本黄色一区二区| 亚洲精品成a人| 91电影在线观看| 亚洲午夜电影网| 91精品国模一区二区三区| 天堂一区二区在线| 欧美一区二区三区性视频| 亚洲成人黄色小说| 91麻豆精品国产综合久久久久久 | 国产精品久久久久精k8| 成+人+亚洲+综合天堂| 亚洲日本中文字幕区| 欧美怡红院视频| 视频一区在线播放| 2024国产精品视频| 成人高清av在线| 亚洲国产成人精品视频| 欧美丰满一区二区免费视频 | 成人精品免费看| 亚洲男人天堂av网| 7777精品伊人久久久大香线蕉完整版 | 亚洲第一综合色| 日韩一卡二卡三卡国产欧美| 日韩精品久久久久久| 国产拍揄自揄精品视频麻豆| 一本到高清视频免费精品| 日韩一区精品视频| 中国色在线观看另类| 欧美日韩一区二区三区四区| 精品一区二区三区免费| 亚洲精品日韩一| 久久久久久麻豆| 欧美三级中文字幕| 国产成人精品亚洲日本在线桃色| 夜夜嗨av一区二区三区中文字幕| 日韩午夜激情av| 91社区在线播放| 精品亚洲成av人在线观看| 亚洲一区免费观看| 国产精品丝袜一区| 精品国产伦一区二区三区观看方式 | 亚洲图片欧美综合| 国产精品青草综合久久久久99| 欧美午夜不卡视频| 91麻豆.com| av午夜一区麻豆| 成人美女在线视频| 国产精一区二区三区| 美女爽到高潮91| 日韩电影在线一区二区| 亚洲免费av网站| 一区二区三区日韩欧美精品 | 五月天一区二区三区| 亚洲美腿欧美偷拍| 一区二区不卡在线播放| 亚洲免费看黄网站| 亚洲第一综合色| 亚洲不卡一区二区三区| 成人av资源在线观看| 国产老女人精品毛片久久| 国产麻豆精品一区二区| 国产精品 欧美精品| 国产成人久久精品77777最新版本| 激情久久久久久久久久久久久久久久 | 不卡电影免费在线播放一区| 成人视屏免费看| 色婷婷av一区二区三区大白胸| 色综合久久六月婷婷中文字幕| 欧美在线观看视频在线| 欧美丰满一区二区免费视频| 日韩午夜在线影院| 久久亚洲一区二区三区四区| 久久精品夜色噜噜亚洲a∨| 1024成人网| 日韩高清一区在线| 国产成人免费视频网站高清观看视频 | 精品欧美一区二区三区精品久久 | 国产一区日韩二区欧美三区| 成人不卡免费av| 6080yy午夜一二三区久久| 精品播放一区二区| 亚洲欧美激情在线| 久久爱另类一区二区小说| 99国内精品久久| 欧美成人a∨高清免费观看| 日韩一区中文字幕| 另类小说欧美激情| av亚洲精华国产精华精| 日韩一区二区在线观看| 国产精品国产三级国产普通话三级| 亚洲国产精品久久人人爱蜜臀| 国产一区二区在线看| 国产精品国产三级国产普通话99| 亚洲国产aⅴ成人精品无吗| 成人性生交大片免费看在线播放 | 亚洲日本一区二区三区| 久久99精品久久只有精品| 欧美日韩一卡二卡三卡| 国产精品久99| 国产精品一区二区在线观看不卡 | 日韩女优毛片在线| 亚洲成年人影院| 日本精品一区二区三区四区的功能| 精品福利视频一区二区三区| 欧美aⅴ一区二区三区视频| 色哟哟一区二区在线观看| 国产欧美1区2区3区| 久久精品国产精品亚洲红杏| 日韩女优电影在线观看| 日韩高清一区在线| 日韩一区二区三区视频| 免费成人小视频| 日韩免费在线观看| 久久99国产精品久久99 | 日韩精品一区二区三区中文精品| 亚洲高清一区二区三区| 7777精品伊人久久久大香线蕉经典版下载 | 国产福利不卡视频| 国产午夜精品一区二区| 欧美大白屁股肥臀xxxxxx| 日韩av一区二区在线影视| 精品美女在线观看| 国产风韵犹存在线视精品| 国产精品久久久久9999吃药| 一本色道久久综合狠狠躁的推荐| 亚洲精品国产品国语在线app| 欧美在线|欧美| 男男gaygay亚洲| 日本一区二区三区免费乱视频| av电影在线观看一区| 一区二区三区精品视频在线| 欧美浪妇xxxx高跟鞋交| 黄页视频在线91| 一区二区理论电影在线观看| 日韩三级精品电影久久久| 国产成人精品网址| 亚洲一区二区影院| 日韩欧美中文字幕一区| 成人高清在线视频| 男女视频一区二区| 中文字幕亚洲区| 欧美mv日韩mv国产网站app| a级精品国产片在线观看| 免费在线成人网| 亚洲天天做日日做天天谢日日欢| 91精品国产美女浴室洗澡无遮挡| 国产激情91久久精品导航| 日韩制服丝袜先锋影音| 国产精品青草久久| 久久综合色一综合色88| 欧美三级日韩在线| 99久久婷婷国产综合精品电影| 国内精品写真在线观看| 亚洲成a人片综合在线| 亚洲女性喷水在线观看一区| 国产精品三级av在线播放| 日韩午夜在线影院| 日韩一级视频免费观看在线| 91福利精品第一导航| 91一区二区三区在线观看|