?
Solved

Synchronized threads

Posted on 1998-05-12
1
Medium Priority
?
202 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 400 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
This video teaches viewers about errors in exception handling.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month9 days, 5 hours left to enroll

764 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