midturm Flashcards

1
Q

How many thread objects execute at once per CPU

A

At any moment, at most one thread object is executing per CPU

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what are the behaviours of thread

A

Thread: defines actual behaviour

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the thread state lifecycle

A
  • new
  • ready
  • running
  • waiting
  • sleeping
  • blocked
  • dead
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what are the behaviours of interface

A

Interface: defines desired behaviour

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How can you put a thread on hold

A
  • yield ()
  • sleep ()
  • join ()
  • wait ()
  • suspend ()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Thread.yield()

A

Static method

Causes the thread executing the method to allow another thread of the same priority to run

Should be used for non-timesliced systems

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

When does a thread die?

A

Threads die when run() method returns

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

how to check if the thread is still viable

A

isAlive()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what arguments does join() take?

A

Join ([timeout])

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

join()

A

Join method causes current thread to wait until the thread of the threadObject on which the join method is called terminates (threadObject.join();)

Join lets another thread finish or gives it a limited amount of time to finish

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Thread.sleep()

A

Static method

Causes thread to pause for a fixed period of time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

what arguments does thread.sleep() take?

A

Thread.sleep (long milis, [int nanos])

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

thread.interrupt()

A

allows another object to interrupt the sleep period

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What exceptions does thread.interrupt() throw?

A

interruptedException – if another thread has interrupted the current thread

IllegalArgumentException – millis is negative or value of nanos is not in the range 0-999999

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Blocked

A

All java I/O methods step out of the running state while paused for response, said to be blocked

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

ThreadGroup

A

Can be dealt with as a unit

Hierarchical relationships – parent/child

Method calls sent to a parent group also sent to all its children

Construct your threads with the ThreadGroupName in the constructor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What does the RMI client do?

A

Obtains a remote reference to one or more remote objects

Invokes methods on those objects

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Synchronization problems

A

Arises when multiple threads access shared data (producer/consumer problem)

Producer fills the buffer/Consumer empties the buffer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

RMI interface support layers:

A

client/server
Stub/skeleton layer
remote reference layer
transport layer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Object monitor lock

A

Every object has a flag associated with it – called monitor lock

Used with the synchronized key word

All methods accessing shared data should synchronize on the same lock object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Stub/skeleton layer

A

responsible for managing the remote object interface between the client and server

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

How many synchronized methods can be active on an object at once?

A

Only 1 synchronized method may be active on an object at once

All other threads trying to acquire the monitor lock will block

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

what does RMI involve

A

RMI involve client and server sides

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Remote reference layer

A

responsible for managing the “liveliness” of the remote objects. Manages the communication between the client/server and virtual machines

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

how to RUN the rmiregistry (2 ways)

A

1 – CMD – run the rmiregistry command on the server

2 – server calls LocateRegistry.createRegistry(portNum)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

how are RMI object parameters passed?

A

Object parameters are passed by value (object not the reference)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

what does the RMI server do?

A

Create some remote objects (local to server)

Make references to those objects available on the network

Wait for clients to invoke methods on those objects

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

how are RMI objects sent?

A

Object serialization is used to send parameters

Object de-serialization is used to reconstitute the parameters in the destination JVM

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

Transport layer

A

actual network/communication layer that is used to send the information between the client and server over the wire. Currently TCP/IP based. Uses serialization.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

what is the RMI registry

A

RMI Registry runs on each machine that hosts remote service objects and accepts queries for services, by default on port 1099 (Registry can be run on a non-default port if desired)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

how to start the RMI registry (2 ways)

A

1 – rmiregistry is a program in the JSDK bin directory, just run it on the server
2 –LocateRegistry.createRegistry(portNum) can be called in the server

THEN:
Start the RMI server
Start the RMI client

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

is multithreading platform dependent or system dependent?

A

Multithreading is platform dependent (windows etc.)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

Synchronized as a block modifier syntax:

A

Synchronized(someObject){…}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

multithreading

A

you can specify that applications contain threads of execution. Each thread designates a portion of a program that may execute concurrently with other threads.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

Synchronized as a method modifier syntax:

A

Public synchronized push (char c)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

Thread synchronization: How many threads does monitor allow to execute at a time?

A

Monitor allows 1 thread at a time to execute a synchronized method on the object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

Synchronized as a method modifier: Public synchronized push (char c)

A

Only 1 thread can be active in the objects synchronized methods

Other threads will block until active thread returns from method

When 1 thread is executing in a synchronized method, ALL other threads are locked out of ALL synchronized methods of that object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

How do you code remote, runnable and thread?

A

Extends Remote
Implements Runnable
Extends Thread

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

Thread synchronization: what happens to the other threads while they wait for the thread to finish executing?

A

All other threads block as the try to invoke the objects synchronized methods

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q

Daemon threads:

A

Threads that run for the benefit of other threads

Run in the background

Do not prevent a program from terminating

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q

Synchronized as a block modifier Synchronized(someObject){…}:

A

Any thread trying to execute the code “…” in that block must obtain the monitor lock of someObject

Only 1 thread at a time can hold the monitor lock of an object

Other threads will block until monitor lock has released when the current thread leaves the block

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q

3 ways to create a thread

A
  1. pass object that implements Runnable to the Thread class constructor and start a new thread: start method
  2. extend the Thread class: in a new class MyThread, override run, instantiate a new MyThread object, start it. ONLY use 2 when you need to override other Thread methods besides run.
  3. use an executor service: java concurrent package
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
43
Q

threadObject.start() method:

A

places thread into runnable state, viable for scheduling for execution by the JVM thread scheduler. Now the thread is runnable, ELIGIBLE to run. Start() method returns to its caller then continues to run concurrently with the newly launched thread.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
44
Q

Thread synchronization: When synchronized method finishes:

A

lock on object is released, monitor lets the highest-priority ready thread attempting to invoke a synchronized method proceed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
45
Q

can executors reuse existing threads or do they create new threads for each call?

A

Executors can reuse existing threads and can improve performance by optimizing the number of threads.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
46
Q

Create a daemon thread:

A

setDaemon(true) method, when only daemonds thread exist in program – program exits.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
47
Q

Executor framework:

A

Used to manage many Runnable’s. creates and manages a group of threads called a thread pool to execute Runnable’s.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
48
Q

ExecutorService Methods:

A

Execute(runnableInstance)

Submit(runnableInstance or callableInstance)

invokeAny(collection_of_Callables, [long timeout, TimeUnit unit])

invokeAll(collection_of_callables, [long timeout, TimeUnit unit])

Shutdown()

shutdownNow()

awaitTermination(long timeout, TimeUnit unit)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
49
Q

CORBA definition

A

Common object request broker architecture

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
50
Q

ExecutorService interface:

A

ExecutorService interface extends executor and declares methods for managing the life cycle of executor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
51
Q

What is CORBA

A

CORBA (Common object request broker architecture): enables software components written in multiple computer languages and running on multiple computers work together

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
52
Q

When do you set a Daemon thread?

A

If thread is daemon it must be set as such before the start method is called

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
53
Q

what does newCachedThreadPool do and return?

A

Executors method newCachedThreadPool returns an executorService that creates new threads as they’re needed by the application.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
54
Q

what type of thread is the garbage collector?

A

Garbage collector is a daemon thread (setDaemon(true);) – false argument means that the thread is not a daemon thread

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
55
Q

ExecutorService.shutdown()

A

ExecutorService method shutdown notified the executorService to stop accepting new tasks but continues executing tasks that have already been submitted.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
56
Q

Java RMI:

A

Java only, interfaces specified in Java, distributed garbage collection integrated with local collectors, generally simpler

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
57
Q

Executors factory methods:

A

newCachedThreadPool

newFixedThreadPool(nThreads)

newScheduledThreadPool(nThreads)

newWorkStealingPool([nThreads])

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
58
Q

Echo client java step 3 explained:

A

3 – perform the processing: get string from user, send string to server, read string object from server, display string to user

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
59
Q

Execute(runnableInstance)

A

returns void so you cannot process any results; best for fire and forget tasks

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
60
Q

Echo server java step 1 explained:

A

1 - Creating a server socket: ServerSocket server = new ServerSocket(portNumber, backlog); - port is the port or application number, backlog is the number of clients that can wait to connect ( default backlog is 50)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
61
Q

invokeAll(collection_of_callables, [long timeout, TimeUnit unit])

A

returns List of Future<>’s representing results of all tasks after all finish (or times out if timeout given)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
62
Q

Echo client in Java Steps:

A

1 – create a socket
2 – get the socket’s IO streams
3 – perform the processing
4 – close the connection

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
63
Q

Echo server java step 3 explained:

A

3 – get the Socket’s I/O streams: inputstream outputstream enable the server to send and receive bytes to/from client. To be able to send strings(serializable object) we use ObjectInputStream / ObjectOutputStream

64
Q

Submit(runnableInstance or callableInstance)

A

Returns Future<> object; access result using get() (blocking) or isDone() (non-blocking); if work causes exception, not thrown on submit(), thrown on get(); can cancel() work

65
Q

Shutdown()

A

service will not accept new work, but existing tasks continue to run

66
Q

Echo client java step 1 explained:

A

1 – create a socket: Socket connection = new Socket (ServerAddress, port); There must be a server at that address already listening for connections at that port

67
Q

Echo server java step 5 explained:

A

5 – close the connection: output.close() , input.close() , connection.close()

68
Q

newWorkStealingPool([nThreads])

A

based on ‘work-stealing’ algorithm designed to maximise parallelism

69
Q

how does a client call a method using RMI?

A

Client uses remote reference to call method

70
Q

Echo server java step 2 explained:

A

2 – wait for a connection: ServerSocket accept() returns a Socket. Server listens indefinitely for a connection by client

71
Q

newScheduledThreadPool(nThreads)

A

pool of fixed size, at most nThreads threads in pool; work runs after some predefined delay and/or periodically

72
Q

Echo server java step 4 explained:

A

4 – perform the processing: server receives objects (strings) from client. Server transmits objects (Strings) to client

73
Q

shutdownNow()

A

performs shutdown() and will interrupt existing tasks possible for tasks to ignore interrupt so could be same as just shutdown()

74
Q

Echo client java step 4 explained:

A

4 – close the connection:inputStream.read() returns value of -1 when it reads EOF. Output.close() input.close() connection.close()

75
Q

newFixedThreadPool(nThreads)

A

pool of fixed size, at most nThreads threads in pool; new work will be blocked if all threads not idle; failed threads terminated and removed from pool, new one added to pool

76
Q

JVM executes threads until:

A

exit() method of class runtime has been called and the security manager has permitted the exit operation OR all non-daemon threads have died (either by returning the call to the run() method or throwing an exception that propagates beyond the run() method).

77
Q

Echo client java step 2 explained:

A

2 – get the socket’s IO streams: client uses socket’s methods getInputStream() and getOutputStream(). (ObjectInputStream input = new ObjectInputStream(connection.getInputStream());)

78
Q

invokeAny(collection_of_Callables, [long timeout, TimeUnit unit])

A

does not return Future<>, instead result of first task to complete (or times out if timeout given)

79
Q

Echo server in Java Steps:

A
1 - Creating a server socket
2 – wait for a connection
3 – get the Socket’s I/O streams
4 – perform the processing
5 – close the connection
80
Q

Wait()

A

puts thread into a waiting state. Threads that invoke wait() can only be processed when notified or interrupted by another thread. Threads must eventually be awakened or the thread will wait forever (deadlock).

81
Q

Marshalling of data:

A

Parameters and return values, both primitive and object are transmitted between client and server

Class ObjectOutputStream converts Serializable object into stream of bytes

Transmits across network

Class ObjectInputStream reconstructs object

82
Q

newCachedThreadPool

A

pool of no particular size, new work causes more threads to be created; existing threads can be re-used if idle; if idle > 60s thread terminated and removed from pool

83
Q

General RMI Architecture 4 steps:

A

1 - Server must first bind a remote object to a service name in the registry

2- Client looks up the service in the server’s registry to establish remote references

3 - Stub serialized the parameters to skeleton

4 - Skeleton invokes the remote method and serialized the result back to the stub

84
Q

awaitTermination(long timeout, TimeUnit unit)

A

wait until all tasks finished, but not forever

85
Q

What is the Stub responsible for?

A

The stub is responsible for sending the remote call over to the server-side skeleton

86
Q

What does the client recieve when looking up object in RMI?

A

Client can look up object and receive a remote reference

87
Q

When a client invokes a remote method, where is the call forwarded?

A

the call is first forwarded to the stub

88
Q

Who registers an RMI object ?

A

Server registers object as remotely accessible

89
Q

What does the Stub layer do?

A

The stub opens a socket to the remote server, marshaling the object parameters and forwarding the resulting data stream to the skeleton.

90
Q

What interface does thread implement? what is the behavior?

A

thread implements runnable interface – behavior of thread is to “run”. We implement a run method so our code runs in a thread

91
Q

Steps for an object becoming a remote object:

A

1 - Remote interface extends the interface java.rmi.Remote

2 - Each method of the interface declares java.rmi.RemoteException in its throw clause in addition to any application-specific exceptions.

3 - RMI passes a remote stub for a remote object to its caller

4 - Stub implements the same remote interfaces as the remote object itself

5 - This stub acts as a proxy for the remote object: it’s a remote reference

6 - Client invokes a method on the stub, which is responsible for carry out the call to that method on the remote object

92
Q

What is the Skeleton layer responsible for?

A

The skeleton is responsible for dispatching the call to the actual remote object implementation

93
Q

How are RMI primitive data types passed?

A

Primitive data types are passed by value.

Copy of the primitive date type is sent to another JVM (Standard machine-independent format is used)

94
Q

What does the Skeleton layer do?

A

A skeleton contains a method that receives the remote calls, unmarshals the parameters and invokes the actual method implementation on the remote object.

95
Q

Client RMI is concerned with?

A

Client concerned with definitions

96
Q

RMI server side installation:

A

Listed classes must be available to its class loader: remote service interface definition, remote service implementations, all other server business code

97
Q

What does stub hide?

A

Stub hides serialization of parameters and the network-level communication in order to present a simple invocation mechanism to the caller

98
Q

Server RMI is concerned with?

A

Server concerned with implementation

99
Q

How does an object become remote?

A

Object becomes a remote object by implementing a remote interface

100
Q

Hibernate is

A

Hibernate is a persistence framework

101
Q

3 states that entities handled by a persistence framework can exist

A

Transient
Persistent
Detached

102
Q

ORM definition

A

(object-relational mapping)

103
Q

RMI client side installation:

A

listed classes must be available to its class loader: remote service interface definitions, server classes for objects used by client (return values), all other client business code

104
Q

Naming method lookup

A

a client to query a registry

Lookup accepts a URL that specifies the host name and name of the desired service, method returns a remote reference to the service object

105
Q

Purpose of hibernate

A

allow you to treat your database as if it stores java objects directly

106
Q

ORM

A

ORM (object-relational mapping) – mapping the objects in java to the relational entities in a database

entity(class) - table
column - property or attribute of class
row - instance of a class(an object)
107
Q

How is the RMI registry accessed?

A

The RMI registry is accessed through a static method of Naming

108
Q

Session factory

A

created once at application startup from a configuration instance

109
Q

Client side callbacks:

A

server needs to call client: client acts as RMI server and exports remote object ( UnicastRemoteObject.export Object(,0)

110
Q

Relational databases:

A

table, attribute of entity – column, instance of entity – row.

111
Q

Detached

A

object was persistent but session is closed. Still lives on in application.

112
Q

Session

A

non-threadsafe object that is used once and discarded for: single request, interaction or single unit of work

113
Q

where are Notify() and notifyAll() called?

A

called in some other thread, returns waiting threads to the ready state.

114
Q

Unit of work: session-per-request:

A

Is a single hibernate transaction. unit of work will span multiple physical database interactions. OpenSession(), getCurrentSession()

115
Q

what code can Wait(), Notify() and NotifyAll() be called in?

A

These methods may only be called in synchronized code

116
Q

Persistent:

A

objects that have representation in the database, associated to a session, changes will persist when unit of work completes.

117
Q

POJO definition:

A

plain old java object

118
Q

where are Wait(), Notify() and NotifyAll() implemented?

A

Implemented in Object class rather than Thread

119
Q

Need to tell hibernate:

A

ipAddress, port, userid, password, database name

120
Q

2 ways to specify how POJOs* map to database tables:

A

1 – Maintaining the mapping info as external XML files. Allows the mapping information to be changed to reflect business changes or schema alterations without rebuilding application

2 – annotations-based mapping – they are immediately in the source code along with the properties that they are associated with

121
Q

Transient:

A

objects are created by the application (new Person();)

122
Q

what is RMI garbage collection called

A

DGC (distributed garbage collector) system

123
Q

Notify() –

A

signals a single, arbitrarily chosen by the implementation, waiting thread. Acts as a signal to a waiting thread that the locked object is now available.

124
Q

Security manager:

A

determines a programs security policy. Sets by constructing a SecurityManager object and calls setSecurityManager method of the system class. Is no manager unless specified.

125
Q

Java class becomes an entity by:

A

1 - @Entity before the class definition in the java class source file

2 - @Id right before: instance of variable for the primary key OR the getter method for the primary key

126
Q

Persistent objects –

A

objects that exist permanently, independently of whether or not our programs are running

127
Q

DGC (distributed garbage collector) system:

A

when client makes a reference, marks object as “dirty”, when client drops reference it notifies server. Interface to DGC is hidden in stubs and skeletons layer.

128
Q

Security policy:

A

each program has a security policy, can be obtained by calling Policy.getPolicy, set by using Policy.setPolicy

129
Q

Client/server in java steps (8):

A

1 – server creates a ServerSocket ( ServerSocket server = new ServerSocket(8080);)

2 – 1)server begins listening for connections on that ServerSocket (at that port). 2)the server.accept() call blocks until a client connects. (Socket connection = server.accept();)

3 – elsewhere, someone runs a client (client is separate program running on separate machine)

4 – client attempts to connect to server. 1)the client uses the socket constructor that takes a String hostname and an integer destination port. 2)source port is the port chosen by TCP/IP stack at runtime (Socket connection = new Socket(“100.121.121.100”, 8080);)

5 – the accept() method on the server now returns and the server is no longer blocked

6 – client and server both get the inputStream and outputStream of the Socket connection (output = connection.getOutputStream(); , input = connection.getInputStream(); )

7 – another client is run on another machine, that client blocks (50 clients will block, 51st will get “connection refused”)

8 – with multithreading the server can accept() (Socket secondConn = server.accept();)

130
Q

NotifyAll() -

A

signals all waiting threads to enter their runnable state.

131
Q

How can a detached object become persistent?

A

Reattached to a session(persistent again) with update() or merge()

132
Q

What exceptions are thrown with notify() and notifyAll()?

A

IllegalMonitorStateException will be thrown if a thread issues wait, notify or notifyall on an object without its lock

InterruptedException is thrown if the waiting thread is interrupted by another

133
Q

RMI programming steps (7):

A

1 - create the remote interfaces for the remote objects to implement

2 – create classes to implement the remote interfaces ( instances will be the remote objects)

3 – create the server ( instantiates and bind remote objects) – remote objects become remote by: 1: implementing a remote interface and 2: extending UnicastRemoteObject OR being exported by servers call to UnicastRemoveObject.exportObject

4 – create the client (looks up service name to get initial remote object reference) – if needed the first remote object should have methods that can return more remote references if needed

5 – compute the interfaces, server, client (javac)

6 – generate stubs and skeletons (rmic)

7 – make class files available through FTP/HTTP for client and server (for our purposes we simply have classes in classpath of client and server machines)

134
Q

What can delete() do to a persistent object?

A

Delete() can make a persistent object transient

135
Q

Use Hibernate session factory to create session objects that manage:

A

connection data, caching, and mappings. Your application is responsible for managing the one session factory

136
Q

can RMI download the definitions of objects classes?

A

RMI provides ability to download the definition of an objects class when the class is not defined in the receiver’s java virtual machine

137
Q

how many session factory should you have?

A

You should only have one session factory (exception: using hibernate to connect 2+ databases, then 1 session per database instance)

138
Q

RMI server side 4 steps:

A

1 - On host machine, server program creates a remote service by first creating a local object that implements that remote interface (service)

2 – exports that object to RMI one of two ways:
1 – either the object itself extends java.rmi.server.UnicastRemoteObject
2 – server calls static method UnicastRemoteObject.export Object(remObj,portNum) – portNum can be 0 (rmi will use arbitrary port) or it can be the same as the one used for the registry

3 – server registers the object in the RMI registry under a public name, using the static method Naming.rebind

4 – this creates a listening service that waits for the clients to connect and request the service.

139
Q

Multithreading: states of a thread (listed)

A
New
Runnable
Waiting
Times waiting state
Blocked state
Terminated state
140
Q

Quantum or timeslice

A

each thread is given a small amount of processor time called Quantum or timeslice

141
Q

what does the operating system handle?

A

The operating system handles the transitions from ready and running.

142
Q

Thread state: New:

A

Thread begins it life in the New and will remain in until the program starts the thread.

143
Q

What happens to the thread when Quantum or timeslice expires?

A

the thread switches back to the ready state and thus loses the processors

If more tasks need to be completed the operating system then assigns another thread to the processor

144
Q

Thread state: Terminated State

A

Runnable thread enters the terminated state when it successfully completes its task or otherwise terminates (perhaps due to an error)

145
Q

The operating systems sees a runnable thread in two states:

A

Ready and running
A runnable thread in ready is a thread that has just been turned into a runnable thread and is currently waiting to be assigned to a processor

A running thread is a thread that’s been a given a processor and is running its task

146
Q

What does timeslicing allow threads to do?

A

Timeslicing allows for each thread that shares an equal-priority to share a processor.

147
Q

Thread state: Timed Waiting State

A

A runnable thread can enter the timed waiting state for a specified interval of time(sleep).

Thread will transition back to runnable when the time interval expires or when the event is waiting for occurs.

Can’t use a processor

148
Q

What priority is given to threads created by other threads?

A

Each new thread inherits the priority of the thread that created it.

149
Q

Thread state: Waiting

A

A runnable thread transitions to the waiting state while it waits for another thread to perform a task.

A waiting thread transitions back to the runnable state only when another thread notifies it to continue executing

Can’t use a processor

150
Q

What causes Indefinite postponement to occur?

A

Indefinite postponement occurs when a higher-priority thread enters the ready state and then the operating system preempts the current low-priority thread.

151
Q

Thread state: Blocked State

A

Runnable thread transitions to the blocked state when it attempts to perform a task that cannot be completed immediately and must temporarily wait until that task completes.

152
Q

What causes deadlock to occur?

A

It occurs when two threads are waiting for the other to finish before they can proceed. This would mean theses threads would forever fail to execute.

153
Q

Thread state: Runnable

A

When a program starts in switches the threads state from New to Runnable. A thread in the runnable state is considered to be executing its task

154
Q

RMI registry client use

A

The registry allows the client to look up a remote service (object) by name

Client uses it to find references to remote objects that they want to invoke

155
Q

RMI registry server use

A

Server uses it advertise their availability

156
Q

Why does hibernate benefit programmers

A

Productivity - gets rid of writing complex SQL statements

Maintainability - Reduces lines of code, makes system more understandable and emphasizes on business logic

Portability - abstracts our application away form the underlying SQL database and dialect