Instructor: Dr. Simina Fluture
CSCI 34 CSCI 34 CSCI 34CSCI 34 0 Summer 201 ummer 201 ummer 201ummer 201ummer 201 4
Project 1 – Due Date: Friday, Aug. 1st
Through its implementation, this project will familiarize you with the creation and execution of threads, and the use of the Thread class methods. In order to synchronize the threads you will have to use the following methods when necessary: run( ), start( ), currentThread( ), getName( ), join( ), yield( ), sleep(time), isAlive( ), getPriority( ), setPriority( ), interrupt( ), and synchronized methods for mutual exclusion. You CANNOT use wait(), notify, or notifyAll( )
Note: the projects must be done individually. No exceptions.
Any collaboration will be treated as cheating.
Online Office Hours
Students come to school and wait (use busy waiting) in front of the computer lab until it is time for the lab to open. Once the lab is open, students enter the lab to the capacity of the lab. If the capacity is reached no additional students can enter the lab. Students beyond the lab capacity will terminate their execution.
There are two types of questions that the student might have. The type and number of questions that each student will be allowed to ask is determined randomly.
Type A: the student can email the teacher up to #questions_A. These questions do not need an immediate answer from the teacher.
Type B: the student will have a chat session with the teacher. During a chat session, the student is allowed to ask at most #questions_B.
Once the student enters the lab, he will take some time to think about his questionA. (use yield( ) and later on sleep(random time)). Each question should contain a timestamp (use age()) and the name of the student (use getName()).
Type A questions: As soon as the student determines his questionA, he will be in a rush to send it to the teacher. (implement this by having the student increase his priority, use getPriority(), and setPriority(). Simulate sending the question by sleep(random time) and immediately after that reset the thread’s priority to the default value). All of the questions sent by students will be answered by the teacher in the order in which they have been sent.
Instructor: Dr. Simina Fluture
After the student is done sending his typeA questions, if he wants to have a chat with the teacher, he needs to wait until the chat session starts and it is his turn to chat. Once it is his turn to chat, he will send a question to the teacher and wait for an answer. If he has fewer than #questions_B he needs to let the teacher know when it is his very last question (when his chat session ends).
After his chatting session, the student will browse the Internet waiting for the online office hour to end (use sleep(time), where time is long enough such that when the online office hours end, the student will be awakened by an interrupt())
Next the students will leave the lab in ascending order of their name. (Implement this using isAlive() and join()). For example if there are 4 student threads named from T0 to T3. T3 will join 2T, T2 will join T1, T1 will join T0 and T0 after some sleep of random time will terminate.
The teacher arrives at his office before the online office hour begins. He spends some time answering typeA questions, but might not be able to answer all of them. Once the time for the online chatting session arrives, he will inform the first student waiting to chat that he is online and can take questions. He chats with students in the order in which they queue for the online chat session.
Once the office hour ends, the teacher will terminate as well. The timer will keep track of the times and, if necessary, signal the correct threads.
Note: set realistic times for the office hour and chatting sessions. For example, the teacher should be able to answer at least 10 typeB questions.
Synchronize the student threads, teacher thread and timer thread following the conditions of the story. Instead of creating a timer thread, you can chose to have the main thread taking track of the specific times. It is your choice.
For example a possible time scale can be (you might consider additional time intervals):
Teacher’s arrival time
Start of online office hour
start online chatting session
end online chatting session
end online office hour
Instructor: Dr. Simina Fluture
Use appropriate System.out.println() statements in the program. Also make use of the age() method provided to keep track of the Threads age and action time.
There are no real messages exchanged; it is just a simulation.
capacity, #Students, #questions_A, and #questions_B should be read as command line arguments.
Don’t hardcode. The program should work under any values for these variables.
Defaults values: capacity 10
#Students 15
#questions_A 4
#questions_B 2
The submission requirements will be posted shortly in a separate file.
Good Luck !!!!!!!!!!!!!!!!!!!
- 浏览: 1010586 次
最新评论
-
18335864773:
很多公司项目 都在使用pageoffice 来操作word,e ...
用java生成word文档 -
Gozs_cs_dn:
请问下博主, 怎样将sitemesh3.xsd绑定 sitem ...
SiteMesh3配置 -
Rose_06:
springside4.0quick-start.bat报错原因 -
ilemma:
我也是刚参见工作啊,经理让自学这个,有些东西不太懂,能不能发个 ...
Apache Shiro在Web中的应用 -
shanbangyou:
你废了
程序员上班打酱油的方法
相关推荐
### 相关知识点 #### 1. 系统概述与功能分析 - **系统功能**:该实训项目涉及一个简单的聊天室系统的...通过实训,学生能够全面掌握聊天室系统的实现原理和技术要点,为进一步深入学习Java网络编程奠定了坚实的基础。
《Java程序设计实训》报告的主题是构建一个多人聊天室,旨在通过这个项目加深对Java语言的理解,特别是Java的多线程、GUI编程以及Socket网络编程技术。以下是对这些知识点的详细说明: 1. **Java语言**:Java是一种...
【Java聊天室实训大学生专用版】是一个专为在校大学生设计的实践项目,旨在帮助学生深入理解和掌握Java编程语言,特别是网络编程与GUI图形用户界面设计的相关技术。该项目包含多个核心功能,如设置背景图片、实现...
《Java高级应用程序综合实训》是一门针对已经掌握了Java基础知识的学生进一步提高其实践能力的课程。通过本课程的学习和实践,学生不仅能够深入理解Java高级编程技术,还能学会如何运用软件工程的思想来解决实际问题...
这个压缩包文件“学校实训JSP项目-Java聊天室程序(java).zip”包含了一个基于Java技术的JSP(JavaServer Pages)聊天室项目,适用于学校实训或毕业设计。这个项目可能涉及了Web开发中的多个重要知识点,让我们逐一...
Java实训课程通常旨在帮助学生和开发者提升其Java编程技能,通过实际操作来加深对语言特性和最佳实践的理解。"java实训.zip"这个压缩包很可能包含了完整的Java实践项目、代码示例、练习题以及可能的教学资源,如教程...
### Java聊天系统实训报告知识点详解 #### 一、实训目的详解 本次实训旨在通过实际项目加深学生对C/S模式下的网络编程技术的理解与应用能力。具体目标包括: 1. **理解C/S模式的软件系统结构**:客户端/服务器...
Java实训报告中的“聊天室”项目是一个典型的C/S(客户端/服务器)架构的应用程序,它结合了Java编程语言、Swing组件以及多线程技术,旨在让学生熟悉Java开发环境下的实时通信实现。以下是对该项目涉及的主要知识点...
【Java实训报告1】 在本实训项目中,我们聚焦于网络应用开发,具体是一个聊天程序的实现。...通过这个实训项目,学生不仅可以提升Java编程技能,还能了解到软件开发的全过程,对网络应用开发有更深入的理解。
Java-J2SE程序设计实训任务书主要关注的是利用Java技术开发一个简单的网络聊天室,该任务旨在提升学生的软件工程实践能力和团队协作意识。以下是相关知识点的详细说明: 1. **需求分析**: - 需求分析是软件开发...
### Java网络聊天室课程设计报告知识点总结 #### 一、项目背景与意义 ...项目不仅涵盖了Java网络编程的基础知识,还涉及到多线程处理、数据库操作等高级技术,对于提升学生的编程能力和实践技能具有重要作用。
Java 实训题目涵盖了多个领域,如图形用户界面(GUI)、文件操作、多线程、数据库交互、网络通信等,旨在提升学生的综合编程能力。以下是各个题目的详细介绍: 1. 记事本程序:利用Java的Swing库创建GUI,实现文本...
【基于JAVA的聊天室设计与实现】是一个计算机应用开发专业的实训项目,旨在通过设计和实现一个网络聊天室,让学生能够深化理解并综合运用JAVA编程、网络通信、多线程、图形用户界面(GUI)和数据库等知识。...
在本项目中,"基于JAVA的局域网文件共享平台P2P实训项目源码"提供了一个实现此类功能的实例,适用于毕业设计或课程设计,是学习和研究P2P技术的好素材。 1. **P2P技术**:P2P(Peer-to-Peer)网络架构是互联网的一...
* 教学场所要求:多媒体教室、实训室、硬件配置环境、软件配置环境、互联网连接等 七、课程资源 * 教材:《Java程序设计基础教程》 * 参考资料:依据本课程标准编写教材,教材应充分表达工程引导、任务驱动的课程...
这一改革思路强调课程建设与实训室建设紧密结合,实验教学与理论教学有机融合,以及校企深度合作。 首先,课程定位是关键。Java语言因其面向对象的特性、强大的可移植性、平台无关性、安全性以及对分布式计算的支持...
同时,缺乏配套的在线学习平台和开放实训室,使得学生课后缺少有效的学习和练习环境,难以及时巩固和加深对知识的理解。 3. 考核方式不合理。传统的考核方式主要依赖于平时成绩和期末笔试,难以全面反映学生的实践...
参考书籍包括《Java程序设计教程与实训》、《Java程序设计》以及《Java编程思想》等,这些资源提供了关于Java编程的基础知识和进阶技巧,有助于理解并实现聊天室系统。 通过这个项目,学生不仅能够掌握Java语言的...
- **项目实训**:通过模拟真实场景的项目开发,让学生亲身体验完整的软件开发流程。 - **教学管理系统**:包括课程管理、成绩记录等功能,便于教师进行教学管理和学生自我评估。 - **交流学习工具**:建立论坛、聊天...
"我的聊天室"这个实训项目旨在帮助学生深入理解和掌握C/S模式的软件系统结构,以及Java中的网络编程技术。C/S模式,即客户端/服务器模式,是分布式应用的一种常见架构,其中客户端负责用户交互,而服务器端处理数据...