一起答
单选

破坏死锁的4个必要条件之一就可以预防死锁。假如规定一个进程在请求新资源之前首先释放已占有的资源则是破坏了(  )条件。

  • A.互斥使用 
  • B.部分分配
  • C.不可剥夺 
  • D.环路等待
参考答案
查看试卷详情
相关试题
  1. 本题中使用了选项卡,窗口中有一个选项卡,总共有“系统”、“声卡”、“显卡”、“网卡”和“帮助”5项选项面。单击各个选项的文字标签后,所选中的选项将为当前选项。“系统”选项上有3个复选按钮,分别控制“声卡”、“显卡”和“网卡”三个选项,选中某个按钮后,它所指示的选项就可用,否则不可用。

    import java.awt.*;

    import java.awt.event.*;

    import javax.swing.*;

    import javax.swing.event.*;

    public class java3 extends JFrame{

    JTabbedPane config=new JTabbedPane:

    public java3{

    super("java3");

    setSize(500,300);

    setDefaultCloseoperation(EXIT_ON_CLOSE);

    JPanel configPane=new JPanel;

    configPane.setLayout(new BoxLayout(config-

    Pane,BoxLayout.Y_AXIS));

    JTextArea question=new JTextArea("下面的哪

    个选项\n"+"你想设置?");

    question.setEditable(false);

    question.setMaximumSize(new Dimension(300,

    50));

    question.setAlignmentX(0.Of);

    question.setBackground(configPane.getBack-

    ground);

    JCheckBox audioCB=new JCheckBox ("声卡",

    true);

    JCheckBox nicCB=new JCheckBox("网卡",

    true);

    JCheckBox tvCB=new JCheckBox("显示卡",

    false);

    configPane.add(Box.createVerticalGlue);

    configPane.add(question);

    configPane.add(audioCB);

    configPane.add(nicCB);

    configPane.add(tvCB);

    configPane.add(Box.ereateVerticalGlue);

    JLabel audioPane=new JLabel("声卡页面");

    JLabel niePane=new JLabel("网卡页面");

    JLabel tvPane=new JLabel("显示卡页面");

    JLabel helpPane=new JLabel("帮助信息");

    audioCB.addItemListener(new TabManager(au-

    dioPane));

    nicCB.addItemListener(new TabManager

    (nicPane));

    tvCB.addItemListener(new TabManager

    (tvPane)):

    config.addTab("系统",null,configPane,"

    Choose Installed Options”);

    config.addTab("声卡",null,audioPane,"Audio

    system configuration”);

    config.addTab("网卡",null,nicPane;"Netwot-

    king configuration");

    config.addTab("显示卡",null,tvPane,"Video

    system configuration");

    config.addTab("帮助",null,helpPane,"How

    Do I…");

    getContentPane.add(config,BorderLayout.

    CENTER);

    }

    class TabManger implements ActionListener{

    Component tab;

    public TabManager(Component tabToManage){

    tab=tabToManage;

    }

    public void ItemStateChanged(ItemEvent ie){

    int index=config.indexOfComponent(tab);

    if(index!=-l){

    config.setEnabledAt(index,ie.getStateChange

    = =ItemEvent.SELECTED);

    }

    this.repaint

    }

    }

    public static void main(String args[]){

    java3 SC=new java3;

    se.setVisible(true);

    }

    }

  2. 本题的功能是通过按钮来选择窗口显示的风格。窗口

    中有三个按钮:“Metal”、“Motif”和“Windows”,单击任何一

    个按钮,就能将窗口的风格改变为按钮名称所对应的风格。

    import java.awt.*;

    import java.awt.event.*;

    import javax.swing.*;

    class PlafPanel extends JPanel implements ActionLis-

    tener

    {public          

    {metaIButton=new JButton("Metal");

    motifButtOn=new J Button("Motif");

    windowsButton=new JButton("Windows");

    add(metalButton);

    add(motifButton);

    add(windowsButton);

    metalButton.addActionListener(this);

    motifButton.addActionListener(this);

    windowsButton.addActionListener(this);

    }

    Dublic void actionPerformed(ActionEvent evt)

    {Object source=evt.getSource;

    String plaf="":

    if(source= =metalButton)

    plaf="javax.swing.plaf.metal.MetalLookAnd-

    Feel";

    else if(source= =motifButton)

    plaf="com.sun.java.swing.plaf.motif.Moti-

    fLookAndFeel";

    else if(source= =windowsButton)

    Dlaf="com.sun.java.swing.plaf.windows.Win-

    dowsLookAndFeel";

    try

    {UIManager.setLookAndFeel(         );

    SwingUtilities.updateComponentTreeUI(this);

    }

    catch(Exception e){)

    }

    private JButton metalButton;

    private JButton motifButton;

    private JButton windowsButton;

    }

    class PlafFrame. extends JFrame

    {public PlafFrame

    { setTitle("simple");

    setSize(300,200);

    addWindowListener(new WindowAdapter

    {public void windowClosing(WindowEvent e)

    {System.exit(O);

    }

    });

    Container contentPane=getContentPane;

    contentPane.add(new PlafPanel);

    }

    }

    public class java2

    {public static void main(String[]args)

    f JFrame. frame=new PlafFrame;

    frame.show;

    }

  3. 本题定义了一个长度为l0的boolean型数组,并给数组元素赋值,要求如果数组元素下标为奇数,则数组元素值

    为false,否则为true。

    public class javal{

    pubhc static void main(String[]args){

    boolean b[]=        ;

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

    if(       )

    b[i]=false;

    else

           

    }

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

    System.Out.print("bE"+i+"]="+b[i]+",");

    }

    }

  4. 下列程序片段中,能通过编译的是(  )。

    • A.public abstract class Animal{ public void speak;}
    • B.public abstract class Animal{ public vold speak;}
    • C.public class Animal{ pubilc abstract void speak;}
    • D.public abstract class Animal{ pubilc abstract void speak;}
  5. 下列叙述中错误的是(  )。

    • A.线性表是由n个元素组成的一个有限序列
    • B.线性表是一种线性结构
    • C.线性表的所有结点有且仅有一个前件和后件
    • D.线性表可以是空表
  6. 下列关于Applet的安全限制的叙述中,错误的是(  )。

    • A.通常情况下,禁止Applet读、写本地文件系统
    • B.通常情况下,禁止Applet向Applet源主机之外的任何主机建立网络连接
    • C.通常情况下,禁止Applet读取系统信息
    • D.通常情况下,禁止Applet加载本地库或方法
  7. JDK中用于存放Java类库文件的文件夹是(  )。

    • A.bin 
    • B.include
    • C.lib
    • D.demo
  8. 下面程序段的输出结果为(  )。

    public class Test

    {

    public static void main(String args[])

    {

    booleana,b,C;

    • a=(3<5):
    • b=(a= =true);    System.out.println("a="+a+"b="+b);
    • c=(b= =false);    System.out.println("b="+b+"c="+c);    }    }
    • A.a=true b=false  b=true c=true
    • B.a=true b=false  b=true c=false
    • C.a=false b=true b=true c=false
    • D.a=false b=false  b=true c=false
  9. 下列代表十六进制整数的是(  )。

    • A.Ol23 
    • B.1900
    • C.fa00
    • D.0xa2
  10. java.io包的File类是(  )。

    • A.字符流类 
    • B.字节流类
    • C.对象流类 
    • D.非流类