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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? 01-01.html

?? master java threads
?? HTML
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
<P>There is a problem with single tasking, however: if a certain task is slow or blocking, it can slow or halt the entire execution of a program. Consider code that implements an input monitor for a user-interface library and blocks until the user types a character, as shown below.
</P>

<TABLE BORDER="2" BORDERCOLOR="#0000" ALIGN="CENTER">
<TR><TD>
<!-- CODE //-->
<PRE>
main(int argc, char **argv)

{

  int c;

  while (1)

  {

    c = getchar();

    if (c == ESC)

      break;

    ProcessKeyboardInput (c);

    ProcessMouseInput();

  }

  exit (0);
}
</PRE>
<!-- END CODE //-->
</TD>
</TR>
</TABLE>

<P><FONT SIZE="+1"><B>Other Examples</B></FONT></P>
<P>Another example of a single-tasking application is a spreadsheet that performs automatic recalculation. The recalculation process may suspend user interaction (with the spreadsheet file or the entire operating system) until the recalculation is complete.
</P>
<P>How can this undesirable situation be alleviated? How can you write an application that allows for particular application events to occur while not freezing the user&#146;s system?</P>
<H4 ALIGN="LEFT"><A NAME="Heading4"></A><FONT COLOR="#000077">&#147;Simulated&#148; Multitasking</FONT></H4>
<P>Back in the &#147;good old days&#148; of programming, application developers utilized a variety of techniques to simulate multitasking in order to avoid blocking waits.
</P>
<P>Among the techniques used to avoid blocking program waits were:</P>
<DL>
<DD><B>&#149;</B>&nbsp;&nbsp;Event loops
<DD><B>&#149;</B>&nbsp;&nbsp;the <B>select()</B> function
<DD><B>&#149;</B>&nbsp;&nbsp;timeouts (using alarms)
<DD><B>&#149;</B>&nbsp;&nbsp;context swapping
</DL>
<P>Writing your own multitasking system can be 1) tedious and time-consuming (making it uneconomical) and 2) nonportable to other operating systems. Solutions have traditionally been proprietary in nature.
</P>
<P>What is necessary and practical is a method of implementing multitasking within an application that is:</P>
<DL>
<DD><B>&#149;</B>&nbsp;&nbsp;portable
<DD><B>&#149;</B>&nbsp;&nbsp;standardized
</DL>
<H4 ALIGN="LEFT"><A NAME="Heading5"></A><FONT COLOR="#000077">Lightweight Processes &amp; Threads</FONT></H4>
<P>UNIX and other operating systems have pioneered the concept of <I>lightweight processes</I>. Lightweight processes are more commonly called <I>threads</I>.</P>
<TABLE WIDTH="90%"><TR>
<TD VALIGN="TOP" WIDTH="5%" ALIGN="LEFT"><IMG SRC="images/01-01i.jpg"></TD>
<TD VALIGN="TOP" ALIGN="LEFT"><B>Thread:</B> also known as a lightweight process, this is a single sequential flow of control within an application or applet process.</TD>
</TR>
</TABLE>
<P>Multithreaded programs typically perform different tasks simultaneously. This creates the illusion of different parts of an application executing simultaneously on different computers or processors.
</P>
<H3><A NAME="Heading6"></A><FONT COLOR="#000077">Threads &amp; Data Space</FONT></H3>
<P>A system that has a single task with multiple threads is different than a true multitasking system.
</P>
<H4 ALIGN="LEFT"><A NAME="Heading7"></A><FONT COLOR="#000077">What Tasks Contain</FONT></H4>
<P>Each task in a multitasking system contains:
</P>
<DL>
<DD><B>&#149;</B>&nbsp;&nbsp;its own data space
<DD><B>&#149;</B>&nbsp;&nbsp;its own register set
</DL>
<TABLE WIDTH="90%">
<TR>
<TD VALIGN="TOP" WIDTH="5%" ALIGN="LEFT"><IMG SRC="images/01-02i.jpg"></TD>
<TD VALIGN="TOP" ALIGN="LEFT">Process switches are slow and expensive.</TD>
</TR>
</TABLE>
<H4 ALIGN="LEFT"><A NAME="Heading8"></A><FONT COLOR="#000077">Thread Characteristics</FONT></H4>
<P>In a multithreaded system, each thread:
</P>
<DL>
<DD><B>&#149;</B>&nbsp;&nbsp;shares the same global data space
<DD><B>&#149;</B>&nbsp;&nbsp;can access the same exact variable in heap memory
<DD><B>&#149;</B>&nbsp;&nbsp;can have private data variables that are allocated on the stack
</DL>
<P><FONT SIZE="+1"><B>Decreased Overhead</B></FONT></P>
<P>In a multithreaded application, each thread runs within the same process space; thus, the overhead of switching between different <I>threads</I> is much less than the overhead of switching between different <I>processes</I> in a multitasking system.</P>
<P>One beneficial aspect of threads is that it is easy for different threads to share global data. In a true multitasking system, it is usually tedious to share data between different processes.</P>
<TABLE WIDTH="90%"><TR>
<TD VALIGN="TOP" WIDTH="5%" ALIGN="LEFT"><IMG SRC="images/01-03i.jpg"></TD>
<TD VALIGN="TOP" ALIGN="LEFT">A system that has a single task with multiple threads is different than a true multitasking system.</TD>
</TR>
</TABLE>
<H3><A NAME="Heading9"></A><FONT COLOR="#000077">Concurrent Execution</FONT></H3>
<P>Each thread in an application can run concurrently. A program typically has a single thread of execution. As the program runs, you can create more threads, as needed. Each thread is typically used to carry out some type of background task.
</P>
<H4 ALIGN="LEFT"><A NAME="Heading10"></A><FONT COLOR="#000077">An Example</FONT></H4>
<P>For example, in the spreadsheet example used earlier, a separate thread could be created which performs recalculations in the background. Another thread could be used to wait for user input.
</P>
<P>The following characteristics apply to threads:</P>
<DL>
<DD><B>&#149;</B>&nbsp;&nbsp;A thread can run continuously in a loop for the entire duration of the program (for example, a thread can continually poll the mouse for movements and button clicks).
<DD><B>&#149;</B>&nbsp;&nbsp;Alternately, a thread can contain a single set of instructions that is executed just once before the thread terminates (such as a one-time spreadsheet recalculation).
</DL>
<TABLE WIDTH="90%">
<TR>
<TD VALIGN="TOP" WIDTH="5%" ALIGN="LEFT"><IMG SRC="images/01-04i.jpg"></TD>
<TD VALIGN="TOP" ALIGN="LEFT">A Java program will run until all nondaemon threads have been terminated.</TD>
</TR>
</TABLE>
<H3><A NAME="Heading11"></A><FONT COLOR="#000077">Writing Threaded Java Apps</FONT></H3>
<H4 ALIGN="LEFT"><A NAME="Heading12"></A><FONT COLOR="#000077">Exercise 1-1: Writing your first threaded Java application</FONT></H4>
<P>The first threaded Java application you will write is a simple counter. This app will count from 1 to 10 and then exit. This file will be a simple console application, run by the stand-alone Java interpreter. Name the file <SMALL>COUNTER1.JAVA</SMALL>, copying the code shown below.</P>

<TABLE BORDER="2" BORDERCOLOR="#0000" ALIGN="CENTER">
<TR><TD>
<!-- CODE //-->
<PRE>
class Counter1

{

  public static void main(String args[])

  {

   Counter1Thread t = new Counter1Thread();

   t.start();

   System.out.println(&#147;main() has finished.&#148;);
 }

}


class Counter1Thread extends Thread

{

  Counter1Thread()

  {

  }


  public void run()

  {

   for (int i = 1; i &lt;= 10; i&#43;&#43;)

   {

      System.out.println(&#147;i is &#148; &#43; i);

    {

   System.out.println(&#147;The thread is finished&#148;);

  }
}
</PRE>
<!-- END CODE //-->
</TD>
</TR>
</TABLE>

<P>The output from the <SMALL>COUNTER1.JAVA</SMALL> program is as follows:</P>

<TABLE BORDER="2" BORDERCOLOR="#0000" ALIGN="CENTER">
<TR><TD>
<!-- CODE //-->
<PRE>
main () has finished.

i is 1

i is 2

i is 3

i is 4

i is 5

i is 6

i is 7

i is 8

i is 9

i is 10

The thread is finished
</PRE>
<!-- END CODE //-->
</TD>
</TR>
</TABLE>

<H4 ALIGN="LEFT"><A NAME="Heading13"></A><FONT COLOR="#000077">Exercise 1-2: Writing a Java app with two threads</FONT></H4>
<P>As a variation on the first application, the following exercise adds another thread. Each thread in the application will count from 1 to 10 and then exit. Name this app <SMALL>COUNTER2.JAVA</SMALL>.</P>

<TABLE BORDER="2" BORDERCOLOR="#0000" ALIGN="CENTER">
<TR><TD>
<!-- CODE //-->
<PRE>
class Counter2

{

  public static void main(String args[])

  {

    Counter2Thread t1 = new Counter2Thread (&#147;First Thread&#148;);

    Counter2Thread t2 = new Counter2Thread (&#147;Second Thread&#148;);

    t1.start();

    t2.start();

    System.out.println(&#147;main() has finished.&#148;);

  }

}


class Counter2Thread extends Thread

{

   Counter2Thread(String szName)

   {

     super (szName);

   }


   public void run()

   {

     for (int i = 1; i &lt;= 10; i&#43;&#43;)

   {

      System.out.println(getName() &#43; &#147;:\ti is &#148; &#43; i);

   }

   System.out.println(getName() &#43; &#147; is finished&#148;);

  }

}
</PRE>
<!-- END CODE //-->
</TD>
</TR>
</TABLE>

<P>The output from this program is as follows:
</P>

<TABLE BORDER="2" BORDERCOLOR="#0000" ALIGN="CENTER">
<TR><TD>
<!-- CODE //-->
<PRE>
main () has finished.

First Thread:  i is 1

First Thread:  i is 2

First Thread:  i is 3

First Thread:  i is 4

First Thread:  i is 5

First Thread:  i is 6

First Thread:  i is 7

First Thread:  i is 8

First Thread:  i is 9

First Thread:  i is 10

Second Thread: i is 1

Second Thread: i is 2

Second Thread: i is 3

Second Thread: i is 4

Second Thread: i is 5

Second Thread: i is 6

Second Thread: i is 7

Second Thread: i is 8

Second Thread: i is 9

Second Thread: i is 10

Second Thread is finished

First Thread is finished
</PRE>
<!-- END CODE //-->
</TD>
</TR>
</TABLE>

<P><FONT SIZE="+1"><B>Starvation</B></FONT></P>
<P>This Java application illustrates one of the interesting problems with multiple threads&#151;<I>starvation</I>. The subject of starvation will be discussed later in this course.</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="../intro.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="../ch02/02-01.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>

<hr width="90%" size="1" noshade><div align="center"><font face="Verdana,sans-serif" size="1">Copyright &copy; <a href="/reference/ddc00001.html">DDC Publishing</a></font></div>
<!-- all of the reference materials (books) have the footer and subfoot reveresed --><!-- reference_subfoot = footer --><!-- reference_footer = subfoot --><!-- BEGIN SUB FOOTER -->	<br>	<img src="/images/dotclear.gif" width="5" height="7" border="0">	</TD>    </TR>	</TABLE>		<table width="100%" border="0" cellspacing="0" cellpadding="0">	<tr>		<td align="left" width="160"><img src="/images/bot_curve.jpg" width="160" alt="" border="0"></td>		<td align="left" valign="top" nowrap><a href="/"><img src="/images/top_tabs/home_bot.gif" alt="home" border="0"></a><!-- <a href="/content/corp.html"><img src="/images/top_tabs/subscribe_bot.gif" alt="Subscribe" border="0"></a> --><a href="/search/"><img src="/images/top_tabs/search_bot.gif" alt="search" border="0"></a><a href="/faq/faq.html"><img src="/images/top_tabs/faq_bot.gif" alt="faq" border="0"></a><a href="/sitemap.html"><img src="/images/top_tabs/sitemap_bot.gif" alt="sitemap" border="0"></a><a href="/contactus.html"><img src="/images/top_tabs/contact_us_bot.gif" alt="contactus" border="0"></a><img src="/images/dotclear.gif" width=260 height="1" alt="" border="0"></td> 	</tr></table>	<table width="100%" bgcolor="#003366" border=0 cellpadding=0 cellspacing=0>		<tr>		<td align="left" width=145><img src="/images/dotclear.gif" width=145 height="1" alt="" border="0"></td>				<!-- END SUB FOOTER -->
<!-- all of the books have the footer and subfoot reveresed --><!-- reference_subfoot = footer --><!-- reference_footer = subfoot --><!-- FOOTER -->			<td align="left" bgcolor="#003366"><table border="0" cellspacing="10" cellpadding="5"><tr><td align="center"><font face="arial, helvetica" size="1" color="#cccccc"><b><a href="/products.html"><font color="#0099CC">Products</font></a>&nbsp;|&nbsp;<a href="/contactus.html"><font color="#0099CC">Contact Us</font></a>&nbsp;|&nbsp;<a href="http://www.earthweb.com/dlink.corp|about_us-jhtml.72.0.-.0.jhtml" target="resource window"><font color="#0099CC">About Us</font></a>&nbsp;|&nbsp;<a href="http://www.earthweb.com/dlink.corp|privacy-jhtml.72.0.-.-.jhtml" target="resource window"><font color="#0099CC">Privacy</font></a>&nbsp;|&nbsp;<a href="http://www.itmarketer.com/" target="resource window"><font color="#0099CC">Ad Info</font></a>&nbsp;|&nbsp;<!--<a href="/consortia/"><font color="#0099CC">Consortia</font></a>&nbsp;|&nbsp;--><a href="/"><font color="#0099CC">Home</font></a></b><br><br>Use of this site is subject to certain <a href="/agreement.html"><font color="#0099CC">Terms &amp; Conditions</font></a>, <a href="/copyright.html"><font color="#0099CC">Copyright &copy; 1996-2000 EarthWeb Inc.</font></a> All rights reserved.  Reproduction in whole or in part in any form or medium without express written <a href="http://www.earthweb.com/dlink.corp|permissions-jhtml.72.0.-.-.jhtml" target="resource window"><font color="#0099CC">permission</font></a> of EarthWeb is prohibited. Read EarthWeb's <A HREF="http://www.earthweb.com/dlink.corp|privacy-jhtml.72.0.-.-.jhtml" target="resource window"><font color="#0099CC">privacy</font></A> statement.</font><br><br></td></tr></table><a href="AITK1a2b3c4d5e6f7g8h9idefcon4.html"><img src="/images/dotclear.gif" border="0" height="1" width="1" align="left"></a></td>		</tr></table><!--DoubleClick Ad BEGIN--><SCRIPT LANGUAGE="JavaScript"><!--document.write('<layer src="http://ad.doubleclick.net/adl/academic.itknowledge.com/homepage;cat=homepage;cat=enterprise;cat=education;cat=it_training;ord=' + ord + '" width="468" height="60" visibility="hide" onload="moveToAbsolute(ph1.pageX, ph1.pageY); visibility=\'show\';" clip="468,60"></layer>');document.write('<LAYER SRC="http://ad.doubleclick.net/adl/itkaca.earthweb.dart/b_aca_soft_dev;a=b_aca_soft_dev4;sz=160x60;ord=' + ord + '" width=160 height=60 visibility="hidden" onLoad="moveToAbsolute(layer1.pageX,layer1.pageY);clip.height=60;clip.width=160; visibility=\'show\';"></LAYER>');//--></SCRIPT> <!--DoubleClick Ad END--></BODY></HTML><!-- END FOOTER -->

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精彩视频一区二区三区| 国产不卡一区视频| 一区精品在线播放| 日韩一区二区三区高清免费看看| 成人午夜精品一区二区三区| 日韩电影网1区2区| 亚洲影视在线观看| 中文字幕av资源一区| 日韩美女视频一区二区在线观看| 色综合久久久久综合99| 成人自拍视频在线| 精品一区二区av| 日韩精品成人一区二区三区| 亚洲人成网站精品片在线观看| 久久免费国产精品| 欧美刺激午夜性久久久久久久| 91激情五月电影| 97精品视频在线观看自产线路二| 国产一区二区三区| 久久av中文字幕片| 首页国产丝袜综合| 亚洲午夜免费电影| 一区二区三区四区中文字幕| 国产精品伦理一区二区| 久久久久久久久蜜桃| 精品国产免费人成在线观看| 欧美精品精品一区| 精品视频在线免费看| 欧美亚洲国产一区在线观看网站 | 亚洲超碰97人人做人人爱| 国产精品久久看| 亚洲国产精品高清| 欧美韩国一区二区| 欧美韩国日本综合| 中文字幕 久热精品 视频在线 | 亚洲精选视频免费看| 国产欧美一区二区三区在线看蜜臀 | 亚洲美女免费在线| 亚洲日本一区二区| 亚洲视频一区二区免费在线观看| 国产精品日韩精品欧美在线| 国产日韩成人精品| 国产精品第四页| 椎名由奈av一区二区三区| 成人欧美一区二区三区黑人麻豆| 亚洲人成小说网站色在线| 亚洲日本在线天堂| 亚洲一区二区三区美女| 亚洲第一激情av| 免费在线观看一区二区三区| 美国十次综合导航| 国产一区不卡视频| av资源站一区| 欧美在线一二三| 91精品国产手机| 亚洲精品一区二区三区香蕉| 国产亚洲综合性久久久影院| 亚洲国产经典视频| 亚洲自拍偷拍图区| 免费欧美在线视频| 大桥未久av一区二区三区中文| 成人app软件下载大全免费| 91久久精品一区二区二区| 欧美日韩一区二区三区在线| 精品国产成人系列| 中文字幕中文字幕在线一区| 亚洲午夜免费福利视频| 蜜臀av一区二区三区| 成人小视频免费在线观看| 色综合激情五月| 日韩一区二区免费在线观看| 国产欧美中文在线| 亚洲第一主播视频| 国产成人日日夜夜| 欧美色图第一页| 国产亚洲美州欧州综合国| 亚洲免费观看视频| 久久不见久久见免费视频1| yourporn久久国产精品| 在线成人高清不卡| 国产精品视频一二三区| 亚洲成在人线在线播放| 国产成人午夜视频| 欧美日免费三级在线| 国产日产欧美精品一区二区三区| 亚洲国产中文字幕| 成人免费精品视频| 欧美日韩免费观看一区三区| 国产精品污网站| 奇米影视在线99精品| 色婷婷av一区二区三区gif| 久久久亚洲精品石原莉奈| 亚洲成a天堂v人片| 成人国产视频在线观看| 日韩欧美电影在线| 亚洲一区二三区| 不卡一二三区首页| 久久亚洲一级片| 日韩高清在线观看| 色婷婷av一区二区三区gif| 国产日韩欧美精品电影三级在线| 手机精品视频在线观看| 91色婷婷久久久久合中文| 26uuu久久综合| 奇米影视一区二区三区| 欧美日韩一区二区在线视频| 亚洲视频图片小说| 岛国一区二区在线观看| 久久综合久久综合九色| 奇米在线7777在线精品 | 91麻豆精品国产自产在线| 亚洲精品免费播放| 成人av电影在线观看| 欧美韩国日本综合| 国产一区二区在线电影| 精品免费日韩av| 久久激情五月激情| 69堂国产成人免费视频| 亚洲午夜在线观看视频在线| 色狠狠综合天天综合综合| 最新欧美精品一区二区三区| 成人午夜精品一区二区三区| 国产欧美日韩在线看| 国产精品一区二区免费不卡| 精品国产污污免费网站入口| 美女脱光内衣内裤视频久久网站 | 久久久综合网站| 久久99精品国产.久久久久久| 欧美一区二区三区视频在线观看| 首页国产欧美日韩丝袜| 欧美日韩大陆在线| 婷婷综合在线观看| 91精品国产综合久久香蕉麻豆| 性久久久久久久| 91精品国模一区二区三区| 六月婷婷色综合| 精品国内片67194| 久久9热精品视频| 精品国产乱码久久| 国产精品一区二区在线播放| 日本一区二区三区视频视频| 成人免费视频播放| 亚洲视频一二三| 欧美日韩在线播放| 青青草国产精品亚洲专区无| 精品国精品国产尤物美女| 岛国精品在线观看| 一区二区在线观看免费| 欧美天天综合网| 日韩精品成人一区二区三区| 精品乱码亚洲一区二区不卡| 高清不卡在线观看| 一区二区三区免费看视频| 欧美日韩和欧美的一区二区| 久久精品99国产精品日本| 国产欧美一区二区三区在线老狼| 99re6这里只有精品视频在线观看 99re8在线精品视频免费播放 | 麻豆91在线播放| 国产区在线观看成人精品| 91亚洲精品一区二区乱码| 亚洲一区二区三区免费视频| 日韩三级视频在线观看| 国产成人久久精品77777最新版本| 国产精品蜜臀av| 欧日韩精品视频| 国产在线视频一区二区| √…a在线天堂一区| 91麻豆精品久久久久蜜臀| 国产精品 日产精品 欧美精品| 亚洲免费av高清| 日韩欧美国产1| 91麻豆文化传媒在线观看| 秋霞影院一区二区| 国产精品免费视频观看| 欧美日韩视频在线第一区 | 国产视频在线观看一区二区三区| 91免费视频大全| 日本不卡一区二区| 欧美国产丝袜视频| 欧美二区三区91| 99久久精品免费看国产| 久久 天天综合| 一区二区三区在线视频观看| 久久女同互慰一区二区三区| 欧美亚洲图片小说| 成人性色生活片| 美女在线观看视频一区二区| 亚洲女与黑人做爰| 久久视频一区二区| 欧美精品 日韩| 99久久精品国产毛片| 激情综合色综合久久| 亚洲一二三四区不卡| 中文字幕不卡在线| 精品欧美乱码久久久久久1区2区| 欧美在线啊v一区| av爱爱亚洲一区| 国产成人午夜电影网| 久久99国产精品久久| 视频一区在线播放|