Solved

Synchronized threads

Posted on 1998-05-12
1
200 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
eclipse console opening separately 2 45
Java class and jar 3 56
IBM TS2900 (3572) Tape Autoloader Java? 12 99
Session in java desktop 5 34
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

740 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