Given that t1 is a reference to a live thread, which is true

题目
单选题
Given that t1 is a reference to a live thread, which is true?()
A

The Thread.sleep() method can take t1 as an argument.

B

The Object.notify() method can take t1 as an argument.

C

The Thread.yield() method can take t1 as an argument.

D

The Thread.setPriority() method can take t1 as an argument.

E

The Object.notify() method arbitrarily chooses which thread to notify.

如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

Which two statements are true about setting the per-thread buffers higher than required?()

A.More memory per thread is beneficial in all scenarios

B.It causes increased overhead due to initial memory allocation

C.It can affect system stability during peak load times, due to swapping

D.It requires increasing the thread_cache_size variable


参考答案:B, C

第2题:

Which three statements are true when the listener handles connection requests to an Oracle 12cdatabase instance with multithreaded architecture enabled In UNIX?()

A. Thread creation must be routed through a dispatcher process

B. The local listener may spawn a now process and have that new process create a thread

C. Each Oracle process runs an SCMN thread.

D. Each multithreaded Oracle process has an SCMN thread.

E. The local listener may pass the request to an existing process which in turn will create a thread.


参考答案:A, D, E

第3题:

( 24 )请阅读下面程序

public class ThreadTest {

public static void main ( String args[ ]){

Thread t1 = new Thread ( new Hello ()):

Thread t2 = new Thread ( new Hello ()):

t l .start ():

t2.start ();

class Hello implements Runnable {

int i ;

public void run (){

while ( true ) {

System.out.println ( "Hello"+i++ ) ;

if ( i=5 ) break :

}

该程序创建线程使用的方法是()

A )继承 Thread 类

B )实现 Runnable 接口

C ) t l.start ()

D ) t2.start ()


正确答案:B

第4题:

Given the following code fragment:     public void create() {     Vector myVect;     myVect = new Vector();      }  Which of the following statements are true?() 

  • A、 The declaration on line 2 does not allocate memory space for the variable myVect.
  • B、 The declaration on line 2 allocates memory space for a reference to a Vector object.
  • C、 The statement on line 2 creates an object of class Vector.
  • D、 The statement on line 3 creates an object of class Vector.
  • E、 The statement on line 3 allocates memory space for an object of class Vector.

正确答案:A,D,E

第5题:

Which statements concerning the methods notify() and notifyAll() are true?  

  • A、Instances of class Thread have a method called notify().
  • B、A call to the method notify() will wake the thread that currently owns the monitor of the object.
  • C、The method notify() is synchronized.
  • D、The method notifyAll() is defined in class Thread.
  • E、When there is more than one thread waiting to obtain the monitor of an object, there is no way to be     sure which thread will be notified by the notify() method.

正确答案:A,E

第6题:

Given:Which statement is true about the class of an object that can reference the variable base? ()

A.It can be any class.

B.No class has access to base.

C.The class must belong to the geometry package.

D.The class must be a subclass of the class Hypotenuse.


参考答案:C

第7题:

下列程序的输出结果是______。 class T44 implements Runnable { public void run() { System.out.print in (Thread.currentThread ( ).getName ( ) + "运行" ); } } public class ex44 { public static void main(String[] args) { Thread t1 = new Thread(new T44(), "t1"); Thread t2 = new Thread(new T44 () , "t2"); t1 .setPriority(Thread. MAX_PRIORITY); t2.setPriority(Thread.MIN_PRIORITY); t2. start (); t1 .start (); } }

A.t1 运行 t2 运行

B.t2 运行 t1 运行

C.t1 运行 t1 运行

D.t2 运行 t2 运行


正确答案:A

第8题:

请阅读下面程序 public class ThreadTest{ public static void main(String args[]) ( Thread t1=new Thread(new Hello()); Thread t2=new Thread(new Hello()); t1.start(); t2.start(); } } class Hello implements Runnable { int i; public void run() { while(true) { System.out.prinfin("Hello"+i++); if(i=5) break; } } } 该程序创建线程使用的方法是

A.继承Thread类

B.实现Runnable接口

C.t1.start()

D.t2.start()


正确答案:B
解析:本题考查线程的创建。Java中,线程的创建有两种方法:
  (1)通过实现Runnable接口创建线程。Runnable接口中只定义了一个run()方法作为线程体。
  (2)通过继承Thread类创建线程。Thread类本身实现了Runnable接口。
  无论使用哪种方法来创建线程,新建的线程不会自动运行,必须调用线程的start()方法,才能运行该线程。
  本题程序中的Hello类实现了Runnable接口,即采用的是第一种方法创建线程。因此,本题的正确答案是选项B。

第9题:

Given this method in a class:  public String toString() {  StringBuffer buffer = new StringBuffer();  buffer.append(‟<‟);  buffer.append(this.name);  buffer.append(‟>‟);  return buffer.toString();  }  Which is true?() 

  • A、 This code is NOT thread-safe.
  • B、 The programmer can replace StringBuffer with StringBuilder with no other changes.
  • C、 This code will perform well and converting the code to use StringBuilder will not enhance the performance.
  • D、 This code will perform poorly. For better performance, the code should be rewritten: return “<“+ this.name + “>”;

正确答案:B

第10题:

public class Test{  public static void main( String[] argv ){  // insert statement here  }  }   Which statement, inserted at line 3, produces the following output?()  Exception in thread “main” java.lang.AssertionError: true at Test.main(Test.java:3)  

  • A、 assert true;
  • B、 assert false;
  • C、 assert false : true;
  • D、 assert false == true;
  • E、 assert false: false;

正确答案:C

更多相关问题