Re: Thread related question



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( );
}

.



Relevant Pages

  • Re: Naming Convention help - Beyond the basics?
    ... MyClass _myClass; ... Here's a poor style solution - you have a variable that's one case off ... public void Foo ... private string _name; ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: .Net Remoting
    ... You're more likely to get an answer to your question in the remoting ... newsgroup, ... > public class MyClass: MarshalByRefObject ... > public void DoSomething() ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Cant connect to remote object
    ... Sam Santiago ... > public class MyClass: MarshalByRefObject ... > public void DoSomething() ... i use of this code to access the remote object. ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: define and call methods in ruby
    ... public void setName ... public class anotherclass extends myclass ... what I'm trying to do is declare similar method as printMessagein ruby. ...
    (comp.lang.ruby)
  • Re: is there a difference between new MyClass; and new MyClass();?
    ... Depending on the 'MyClass', ... Oops, your right. ... Sorry for my bad advice :-( ...
    (comp.lang.cpp)