Re: Thread related question
- From: "farseer" <farseer@xxxxxxxxxxxxx>
- Date: 9 May 2005 09:07:49 -0700
thanks for the responses. I am not sure that i want anythig in
particular, just looking for advice from the experienced...so not sure
ArrayBlockingQueue is what i was looking for. Basically, i would like
to know if there are performance issues with one thread accessing a
property of a class in another thread, if that class has a while loop
that is processing most of the time...for instance, below is the
scenario. In this case, will ThreadC have an issue accessing the
Vector? Now i realize that synchronzing may be an issue, but not
really asking about that...what i want to know is that when ThreadA
wants to access MyClass.list, does it have to wait for processing in
MyClass.process to finish doing 'somehting', or can it access it
immediately since it has a reference to it already?
class MyClass{
public Vector list;
public MyClass( ){ }
public process( )
{
while ( true ) { \\do something that processes 90% of the time}
}
}
class ThreadClass implements Runnable {
private Vector pointerToMyClassVector;
public ThreadClass( Vector list ) {
pointerToMyClassVector = list;
}
public void run( ){
....
list.add( xxx );
....
}
}
.....
void main ( String[] args )
{
MyClass myClass = new MyClass( );
ThreadClass threadC = new ThreadClass( myClass.list );
( new Thread ( threadC ) ).start( )
myClass.process( );
}
.
- Follow-Ups:
- Re: Thread related question
- From: Wibble
- Re: Thread related question
- References:
- Thread related question
- From: farseer
- Re: Thread related question
- From: Wibble
- Thread related question
- Prev by Date: Re: Color of JComboBox
- Next by Date: Re: Problem with streamed ZIP file and Windows XP
- Previous by thread: Re: Thread related question
- Next by thread: Re: Thread related question
- Index(es):
Relevant Pages
|