Solved

Synchronized threads

Posted on 1998-05-12
1
190 Views
Last Modified: 2010-04-16
I have this class that is instantiated multiple times.  Each instance needs to talk to the com port.  The problem I am having is synchronized only works on one object.   So what I am trying to figure out is how get get a group of the objects to be syncronized together.  Each instance will have one com port to be used.  So if two instances are not using the same com port there is no reason to synchronize.  Also instead of a com port it might be a socket.  

In other words how can I group objects together to be synchronized.

0
Comment
Question by:micah
1 Comment
 

Accepted Solution

by:
knollc earned 100 total points
ID: 1220953
Hello,
  Try this:  have a static class that has one synchronized method: sendMsg().  On startup, have the static class grab on to the comm port, and all client objects wishing to send a message to the commport will use the static class' sendMsg() function.  Create one instance of the static class per COMM port that is available (I would name the class that hooks to a COMM port after the comm port it is controlling (ie, COMM1.sendMsg(SomeString), COMM2.sendMsg(SomeString), etc).  I hope this helps.

-Chris

0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

775 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question